summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2013-02-20 10:45:06 +0100
committerAlexander Bokovoy <ab@samba.org>2013-02-22 16:36:14 +0100
commitc647169e2850cf6f8ea8705d7008e3ce4d24f454 (patch)
tree2aaa7b2089b8efc36c352f3de6d4f76aa02d70b0
parent62136067712aad9cff8c757b2bfb228ebbecfd76 (diff)
downloadsamba-c647169e2850cf6f8ea8705d7008e3ce4d24f454.tar.gz
samba-c647169e2850cf6f8ea8705d7008e3ce4d24f454.tar.bz2
samba-c647169e2850cf6f8ea8705d7008e3ce4d24f454.zip
s3-vfs: Don't leak file descriptor on error.
Reviewed-by: Alexander Bokovoy <ab@samba.org>
-rw-r--r--source3/modules/vfs_crossrename.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/source3/modules/vfs_crossrename.c b/source3/modules/vfs_crossrename.c
index 19a182c453..9bb42b9958 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 )