s3-vfs: Don't leak file descriptor on error. Reviewed-by: Alexander Bokovoy <ab@samba...
authorAndreas Schneider <asn@samba.org>
Wed, 20 Feb 2013 09:45:06 +0000 (10:45 +0100)
committerKarolin Seeger <kseeger@samba.org>
Wed, 27 Feb 2013 10:40:54 +0000 (11:40 +0100)
source3/modules/vfs_crossrename.c

index 19a182c453cc0229f608374753c9354c12adf4f3..9bb42b9958ee9c793f342736dbbd97b378aa1a30 100644 (file)
@@ -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 )