From 22928b0cea0fce41efd211d28a14cbdbdb0c0d06 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 20 Feb 2013 10:45:06 +0100 Subject: [PATCH] s3-vfs: Don't leak file descriptor on error. Reviewed-by: Alexander Bokovoy --- source3/modules/vfs_crossrename.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source3/modules/vfs_crossrename.c b/source3/modules/vfs_crossrename.c index 19a182c453c..9bb42b9958e 100644 --- a/source3/modules/vfs_crossrename.c +++ b/source3/modules/vfs_crossrename.c @@ -73,8 +73,10 @@ static int copy_reg(const char *source, const char *dest) if((ifd = open (source, O_RDONLY, 0)) < 0) return -1; - if (unlink (dest) && errno != ENOENT) + if (unlink (dest) && errno != ENOENT) { + close(ifd); return -1; + } #ifdef O_NOFOLLOW if((ofd = open (dest, O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW, 0600)) < 0 ) -- 2.11.4.GIT