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

Re: [libvirt] [PATCH] openvz_conf.c: don't use undefined local, "net"



On Thu, Sep 03, 2009 at 12:38:43PM +0200, Jim Meyering wrote:
> Jim Meyering wrote:
> 
> > This looks like a real bug.
> >
> >>From 170af3320e68a0ac2cfe854fba28abe0e4040d2c Mon Sep 17 00:00:00 2001
> > From: Jim Meyering <meyering redhat com>
> > Date: Thu, 3 Sep 2009 11:24:44 +0200
> > Subject: [PATCH] openvz_conf.c: don't use undefined local, "net"
> >
> > * src/openvz_conf.c (openvzReadNetworkConf): Upon openvzRead... failure,
> > simply return -1, rather than "goto error;" where an uninitialized
> > "net" could be dereferenced.
> > ---
> >  src/openvz_conf.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/src/openvz_conf.c b/src/openvz_conf.c
> > index a172fe3..b1cb31a 100644
> > --- a/src/openvz_conf.c
> > +++ b/src/openvz_conf.c
> > @@ -197,7 +197,7 @@ openvzReadNetworkConf(virConnectPtr conn,
> >          openvzError(conn, VIR_ERR_INTERNAL_ERROR,
> >                   _("Could not read 'IP_ADDRESS' from config for container %d"),
> >                    veid);
> > -        goto error;
> > +        return -1;
> >      } else if (ret > 0) {
> >          token = strtok_r(temp, " ", &saveptr);
> >          while (token != NULL) {
> 
> When I reran the tool, there was still a potential NULL-deref,
> so I propose to do this instead:
> 
> >From d120f7693f1ae0e213bd9e8b244968b49dfe1427 Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering redhat com>
> Date: Thu, 3 Sep 2009 12:33:11 +0200
> Subject: [PATCH] openvz_conf.c: don't use undefined local, "net"
> 
> * src/openvz_conf.c (openvzReadNetworkConf): Initialize "net".
> Otherwise, upon openvzRead... failure, we would "goto error;"
> where an uninitialized "net" could be dereferenced.
> ---
>  src/openvz_conf.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/src/openvz_conf.c b/src/openvz_conf.c
> index a172fe3..41c6684 100644
> --- a/src/openvz_conf.c
> +++ b/src/openvz_conf.c
> @@ -183,7 +183,7 @@ openvzReadNetworkConf(virConnectPtr conn,
>                        virDomainDefPtr def,
>                        int veid) {
>      int ret;
> -    virDomainNetDefPtr net;
> +    virDomainNetDefPtr net = NULL;
>      char temp[4096];
>      char *token, *saveptr = NULL;
> 

ACK

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


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