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
This commit is contained in:
parent
33da4e5bd8
commit
2e22b91434
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=136554
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user