[Pkg-libvirt-commits] [libguestfs] 67/266: daemon: blkid: fix memory issues in "no -p/-i" mode

Hilko Bengen bengen at moszumanska.debian.org
Fri Oct 3 14:41:43 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 ad4ba5997be030ee4b67614d9e6004107482bbc3
Author: Pino Toscano <ptoscano at redhat.com>
Date:   Fri Aug 8 14:58:08 2014 +0200

    daemon: blkid: fix memory issues in "no -p/-i" mode
    
    Fix the memory issues in the implementation that uses no -p nor -i:
    - use add_string_nodup to add results from get_blkid_tag (which returns
      new strings), so those strings are not leaked
    - use free_stringslen to clean the hash on error, as in such case the
      stringbuf will not be terminated with a null entry, thus causing
      free_strings to crash
---
 daemon/blkid.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/daemon/blkid.c b/daemon/blkid.c
index 83ff355..b98c155 100644
--- a/daemon/blkid.c
+++ b/daemon/blkid.c
@@ -197,19 +197,19 @@ blkid_without_p_i_opt(const char *device)
   if (add_string (&ret, "TYPE") == -1) goto error;
   s = get_blkid_tag (device, "TYPE");
   if (s == NULL) goto error;
-  if (add_string (&ret, s) == -1)
+  if (add_string_nodup (&ret, s) == -1)
     goto error;
 
   if (add_string (&ret, "LABEL") == -1) goto error;
   s = get_blkid_tag (device, "LABEL");
   if (s == NULL) goto error;
-  if (add_string (&ret, s) == -1)
+  if (add_string_nodup (&ret, s) == -1)
     goto error;
 
   if (add_string (&ret, "UUID") == -1) goto error;
   s = get_blkid_tag (device, "UUID");
   if (s == NULL) goto error;
-  if (add_string (&ret, s) == -1)
+  if (add_string_nodup (&ret, s) == -1)
     goto error;
 
   if (end_stringsbuf (&ret) == -1) goto error;
@@ -217,7 +217,7 @@ blkid_without_p_i_opt(const char *device)
   return ret.argv;
 error:
   if (ret.argv)
-    free_strings (ret.argv);
+    free_stringslen (ret.argv, ret.size);
   return NULL;
 }
 

-- 
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