diff options
author | yar <yar@FreeBSD.org> | 2003-11-15 11:08:26 +0000 |
---|---|---|
committer | yar <yar@FreeBSD.org> | 2003-11-15 11:08:26 +0000 |
commit | 759577e79318807e678ac94b05eff4fa13d14673 (patch) | |
tree | 284150c8e2b4fb896c13bc9455d0d87b5856eb0b /libexec/ftpd | |
parent | e44f1268ea6c6ba3d8a0b5200b63319b96b9fd76 (diff) | |
download | FreeBSD-src-759577e79318807e678ac94b05eff4fa13d14673.zip FreeBSD-src-759577e79318807e678ac94b05eff4fa13d14673.tar.gz |
If a file to send in ASCII mode already has CRLF as end-of-line,
don't add excessive CR on the wire.
PR: bin/59285
Submitted by: Andrey Beresovsky <and at rsu.ru>
MFC after: 1 week
Diffstat (limited to 'libexec/ftpd')
-rw-r--r-- | libexec/ftpd/ftpd.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c index bcb7bef..40741f0 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -1970,7 +1970,7 @@ pdata_err: static int send_data(FILE *instr, FILE *outstr, off_t blksize, off_t filesize, int isreg) { - int c, filefd, netfd; + int c, cp, filefd, netfd; char *buf; off_t cnt; @@ -1978,16 +1978,18 @@ send_data(FILE *instr, FILE *outstr, off_t blksize, off_t filesize, int isreg) switch (type) { case TYPE_A: + cp = '\0'; while ((c = getc(instr)) != EOF) { if (recvurg) goto got_oob; byte_count++; - if (c == '\n') { + if (c == '\n' && cp != '\r') { if (ferror(outstr)) goto data_err; (void) putc('\r', outstr); } (void) putc(c, outstr); + cp = c; } if (recvurg) goto got_oob; |