Richard W.M. Jones
2015-Oct-09 11:34 UTC
[Libguestfs] [PATCH] inspect: Don't free uninitialized string.
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
Pino Toscano
2015-Oct-09 11:49 UTC
Re: [Libguestfs] [PATCH] inspect: Don't free uninitialized string.
On Friday 09 October 2015 12:34:21 Richard W.M. Jones wrote:> 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;ACK. Sorry for the small regression, and thanks for fixing it. -- Pino Toscano
Reasonably Related Threads
- [PATCH] inspect: try to use /etc/os-release on Linux guests
- Re: [PATCH 2/3] New API: part-get-name (RHBZ#593511).
- [PATCH 2/2] inspect: switch to version struct for os major/minor version
- [PATCH] ocfs2: Use xs->bucket to set xattr value outside.
- [PATCH 0/2] src: introduce an helper version struct