Olaf Hering
2013-May-30 23:38 UTC
[Libguestfs] [PATCH] inspection: handle empty file in parse_suse_release
If /etc/SuSE-release is empty then lines[0] is NULL, which is passed to strdup. As a result virt-inspector will segfault. This was introduced in commit 763ec36cf0c6ffa6d359b65ff7f1ee9ab1c7361e. Signed-off-by: Olaf Hering <olaf@aepfle.de> --- src/inspect-fs-unix.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c index 5fabaa2..c7d52c4 100644 --- a/src/inspect-fs-unix.c +++ b/src/inspect-fs-unix.c @@ -339,6 +339,8 @@ parse_suse_release (guestfs_h *g, struct inspect_fs *fs, const char *filename) return -1; /* First line is dist release name */ + if (lines[0] == NULL) + goto out; fs->product_name = safe_strdup (g, lines[0]); if (fs->product_name == NULL) goto out;
Richard W.M. Jones
2013-May-31 07:58 UTC
Re: [Libguestfs] [PATCH] inspection: handle empty file in parse_suse_release
On Fri, May 31, 2013 at 01:38:31AM +0200, Olaf Hering wrote:> If /etc/SuSE-release is empty then lines[0] is NULL, which is passed to > strdup. As a result virt-inspector will segfault. > This was introduced in commit 763ec36cf0c6ffa6d359b65ff7f1ee9ab1c7361e. > > Signed-off-by: Olaf Hering <olaf@aepfle.de> > --- > src/inspect-fs-unix.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c > index 5fabaa2..c7d52c4 100644 > --- a/src/inspect-fs-unix.c > +++ b/src/inspect-fs-unix.c > @@ -339,6 +339,8 @@ parse_suse_release (guestfs_h *g, struct inspect_fs *fs, const char *filename) > return -1; > > /* First line is dist release name */ > + if (lines[0] == NULL) > + goto out; > fs->product_name = safe_strdup (g, lines[0]); > if (fs->product_name == NULL) > goto out;This isn't complete because safe_strdup cannot return NULL. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
Olaf Hering
2013-May-31 08:22 UTC
Re: [Libguestfs] [PATCH] inspection: handle empty file in parse_suse_release
On Fri, May 31, Richard W.M. Jones wrote:> On Fri, May 31, 2013 at 01:38:31AM +0200, Olaf Hering wrote: > > If /etc/SuSE-release is empty then lines[0] is NULL, which is passed to > > strdup. As a result virt-inspector will segfault. > > This was introduced in commit 763ec36cf0c6ffa6d359b65ff7f1ee9ab1c7361e. > > > > Signed-off-by: Olaf Hering <olaf@aepfle.de> > > --- > > src/inspect-fs-unix.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c > > index 5fabaa2..c7d52c4 100644 > > --- a/src/inspect-fs-unix.c > > +++ b/src/inspect-fs-unix.c > > @@ -339,6 +339,8 @@ parse_suse_release (guestfs_h *g, struct inspect_fs *fs, const char *filename) > > return -1; > > > > /* First line is dist release name */ > > + if (lines[0] == NULL) > > + goto out; > > fs->product_name = safe_strdup (g, lines[0]); > > if (fs->product_name == NULL) > > goto out; > > This isn't complete because safe_strdup cannot return NULL.Ok, the other change looks good. Thanks. Olaf
Reasonably Related Threads
- Re: [PATCH] inspection: handle empty file in parse_suse_release
- ATTN: Denial of service attack possible on libguestfs 1.21.x, libguestfs.1.22.0
- [PATCH v2] inspect: return osinfo short IDs for recent Windows versions
- [PATCH] inspect: return osinfo short IDs for recent Windows versions
- [PATCH 0/2] src: introduce an helper version struct