[Pkg-libvirt-commits] [libguestfs] 47/266: make-fs: do not leak the fd from mkstemp

Hilko Bengen bengen at moszumanska.debian.org
Fri Oct 3 14:41:40 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag debian/1%1.27.35-1
in repository libguestfs.

commit 8ea6b3e03c8cccdd18a7910e9e5da75ee1e27807
Author: Pino Toscano <ptoscano at redhat.com>
Date:   Mon Jul 28 17:27:30 2014 +0200

    make-fs: do not leak the fd from mkstemp
---
 make-fs/make-fs.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/make-fs/make-fs.c b/make-fs/make-fs.c
index 9c11fef..406aa1d 100644
--- a/make-fs/make-fs.c
+++ b/make-fs/make-fs.c
@@ -382,15 +382,18 @@ estimate_input (const char *input, uint64_t *estimate_rtn, char **ifmt_rtn)
   char line[256];
   size_t len;
   CLEANUP_FREE char *tmpdir = guestfs_get_tmpdir (g);
+  int fd;
 
   if (asprintf (&tmpfile, "%s/makefsXXXXXX", tmpdir) == -1) {
     perror ("asprintf");
     return -1;
   }
-  if (mkstemp (tmpfile) == -1) {
+  fd = mkstemp (tmpfile);
+  if (fd == -1) {
     perror (tmpfile);
     return -1;
   }
+  close (fd);
 
   if (stat (input, &statbuf) == -1) {
     perror (input);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list