[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]