daemon: upload: fix fd leak on lseek failure

Make sure to not leak the file descriptor in the upload() function, in
case lseek() fails.

(cherry picked from commit fced132718)
This commit is contained in:
Pino Toscano
2018-04-30 13:07:50 +02:00
committed by Richard W.M. Jones
parent 62b59441e3
commit 0fdf1b6269

View File

@@ -111,6 +111,7 @@ upload (const char *filename, int flags, int64_t offset)
if (lseek (fd, offset, SEEK_SET) == -1) {
err = errno;
ignore_value (cancel_receive ());
close (fd);
errno = err;
reply_with_perror ("lseek: %s", filename);
return -1;