check return value of lseek()

fixes CID 27702 found by Coverity
This commit is contained in:
Christian Beer 2015-10-28 17:10:30 +01:00
parent 9951ffcea0
commit 005957aab9
1 changed files with 12 additions and 1 deletions

View File

@ -205,7 +205,18 @@ int copy_socket_to_file(FILE* in, char* path, double offset, double nbytes) {
path, (int)sbuf.st_size, offset
);
}
if (offset) lseek(fd, offset, SEEK_SET);
if (offset) {
if (-1 == lseek(fd, offset, SEEK_SET)) {
log_messages.printf(MSG_CRITICAL,
"lseek(%s, %.0f) failed: %s (%d).\n",
this_filename, offset, strerror(errno), errno
);
close(fd);
return return_error(ERR_TRANSIENT,
"can't resume partial file %s: %s\n", path, strerror(errno)
);
}
}
if (sbuf.st_size > offset) {
log_messages.printf(MSG_CRITICAL,
"file %s length on disk %d bytes; host upload starting at %.0f bytes.\n",