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

Richard W.M. Jones rjones at redhat.com
Fri May 31 07:58:03 UTC 2013


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

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




More information about the Libguestfs mailing list