From 2e22b91434ede570526a309f4bce2bae5dfcafdf Mon Sep 17 00:00:00 2001 From: Yaroslav Tykhiy Date: Fri, 15 Oct 2004 09:31:08 +0000 Subject: Account for the fact that sendfile(2) may hit the end of file prematurely, e.g., if the file has been truncated by someone else. PR: bin/72649 Submitted by: Oleg Koreshkov (portions) MFC after: 2 weeks --- libexec/ftpd/ftpd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'libexec') diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c index 90373c61d7cc..f2aef51f2c7e 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -2038,6 +2038,7 @@ send_data(FILE *instr, FILE *outstr, off_t blksize, off_t filesize, int isreg) if (isreg) { + char *msg = "Transfer complete."; off_t offset; int err; @@ -2062,10 +2063,20 @@ send_data(FILE *instr, FILE *outstr, off_t blksize, off_t filesize, int isreg) goto data_err; } + + /* + * We hit the EOF prematurely. + * Perhaps the file was externally truncated. + */ + if (cnt == 0) { + msg = "Transfer finished due to " + "premature end of file."; + break; + } } transflag = 0; - reply(226, "Transfer complete."); + reply(226, msg); return (0); } -- cgit v1.3