Avoid leaving a file open on error return.
authorWayne Davison <wayned@samba.org>
Tue, 15 Jan 2019 18:38:00 +0000 (10:38 -0800)
committerWayne Davison <wayned@samba.org>
Tue, 15 Jan 2019 18:38:00 +0000 (10:38 -0800)
util.c

diff --git a/util.c b/util.c
index fbbfd8b..235afa8 100644 (file)
--- a/util.c
+++ b/util.c
@@ -342,6 +342,7 @@ int copy_file(const char *source, const char *dest, int ofd, mode_t mode)
                if (robust_unlink(dest) && errno != ENOENT) {
                        int save_errno = errno;
                        rsyserr(FERROR_XFER, errno, "unlink %s", full_fname(dest));
+                       close(ifd);
                        errno = save_errno;
                        return -1;
                }