summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorYaroslav Tykhiy <ytykhiy@gmail.com>2004-11-13 12:28:50 +0000
committerYaroslav Tykhiy <ytykhiy@gmail.com>2004-11-13 12:28:50 +0000
commit33827169c5e33dc2cfc67fd99ae204fc65f57517 (patch)
treeb458d963687954904eae655835daa89b962c7ff2 /libexec
parent12a857a424a05130a5f151312df1b47758ac652e (diff)
Notes
Diffstat (limited to 'libexec')
-rw-r--r--libexec/ftpd/ftpd.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index 90373c61d7cc..e8e25b4039ac 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -2038,12 +2038,13 @@ 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;
- err = cnt = offset = 0;
+ cnt = offset = 0;
- while (err != -1 && filesize > 0) {
+ while (filesize > 0) {
err = sendfile(filefd, netfd, offset, 0,
(struct sf_hdtr *) NULL, &cnt, 0);
/*
@@ -2057,15 +2058,25 @@ send_data(FILE *instr, FILE *outstr, off_t blksize, off_t filesize, int isreg)
filesize -= cnt;
if (err == -1) {
- if (!cnt)
+ if (cnt == 0 && offset == 0)
goto oldway;
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);
}