[Pkg-libvirt-commits] [libguestfs] 125/266: drives: Add comments about fragile string handling.

Hilko Bengen bengen at moszumanska.debian.org
Fri Oct 3 14:41:50 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 0fd95e2b9fb9e49cf455b30cd4b85b7d7c354988
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Tue Aug 19 12:11:06 2014 +0100

    drives: Add comments about fragile string handling.
    
    GC FTW.
---
 src/drives.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/drives.c b/src/drives.c
index 85c1495..b925996 100644
--- a/src/drives.c
+++ b/src/drives.c
@@ -676,6 +676,11 @@ parse_one_server (guestfs_h *g, const char *server, struct drive_server *ret)
   char *port_str;
   int port;
 
+  /* Note! Do not set any string field in *ret until you know the
+   * function will return successfully.  Otherwise there can be a
+   * double-free in parse_servers -> free_drive_servers below.
+   */
+
   ret->transport = drive_transport_none;
 
   if (STRPREFIX (server, "tcp:")) {
@@ -739,6 +744,9 @@ parse_servers (guestfs_h *g, char *const *strs,
     return 0;
   }
 
+  /* Must use calloc here to avoid freeing garbage along the error
+   * path below.
+   */
   servers = safe_calloc (g, n, sizeof (struct drive_server));
 
   for (i = 0; i < n; ++i) {

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