[Libguestfs] [PATCH] inspect: Don't free uninitialized string.

Richard W.M. Jones rjones at redhat.com
Fri Oct 9 11:34:21 UTC 2015


libguestfs: trace: v2v: read_lines "/etc/os-release"
[...]
libguestfs: trace: v2v: read_lines = ["NAME=Fedora", "VERSION="20 (Heisenbug)"", "ID=fedora", "VERSION_ID=20", "PRETTY_NAME="Fedora 20 (Heisenbug)"", "ANSI_COLOR="0;34"", "CPE_NAME="cpe:/o:fedoraproject:fedora:20"", "HOME_URL="https://fedoraproject.org/"", "BUG_REPORT_URL="https://bugzilla.redhat.com/"", "REDHAT_BUGZILLA_PRODUCT="Fedora"", "REDHAT_BUGZILLA_PRODUCT_VERSION=20", "REDHAT_SUPPORT_PRODUCT="Fedora"", "REDHAT_SUPPORT_PRODUCT_VERSION=20"]

At this point libguestfs segfaulted.

It seems as if 'major' is not used here, so don't try to free it.

This fixes commit 32d19e3289bc259901f77398703f16cf6eabd510.
---
 src/inspect-fs-unix.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c
index cda1b5d..3d19276 100644
--- a/src/inspect-fs-unix.c
+++ b/src/inspect-fs-unix.c
@@ -232,7 +232,6 @@ parse_os_release (guestfs_h *g, struct inspect_fs *fs, const char *filename)
         char buf[value_len + 1];
         snprintf (buf, sizeof buf, "%*s", (int) value_len, value);
         major_version = guestfs_int_parse_unsigned_int (g, buf);
-        free (major);
         /* Handle cases where VERSION_ID is not a number. */
         if (major_version != -1)
           minor_version = 0;
-- 
2.5.0




More information about the Libguestfs mailing list