From f233dffbd6bf65a08d0d6ce1050eb9c6ed7723cb Mon Sep 17 00:00:00 2001
From: Wayne Davison <wayned@samba.org>
Date: Tue, 15 Jan 2019 10:38:00 -0800
Subject: [PATCH 21/36] Avoid leaving a file open on error return.

Signed-off-by: root <root@localhost.localdomain>
---
 util.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/util.c b/util.c
index fbbfd8ba..235afa82 100644
--- a/util.c
+++ b/util.c
@@ -346,6 +346,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;
 		}
-- 
2.19.1

