[Libguestfs] [PATCH] inspection: handle empty file in parse_suse_release

Olaf Hering olaf at aepfle.de
Thu May 30 23:38:31 UTC 2013


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




More information about the Libguestfs mailing list