[libvirt] [PATCH] conf: Fix invalid pointer check in virDomainObjGetDefs

Peter Krempa pkrempa at redhat.com
Thu Jun 4 11:50:15 UTC 2015


On Thu, Jun 04, 2015 at 07:44:20 -0400, John Ferlan wrote:
> 
> 
> On 06/04/2015 07:28 AM, Peter Krempa wrote:
> > Coverity rightfully determined that in commit 3d021381c71221e563182f03
> > I made a mistake in the first check if @persDef is not NULL is
> > dereferencing it rather than checking.
> > ---
> > 
> > Pushed as trivial.
> > 
> >  src/conf/domain_conf.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> > index 77e198c..68d28f6 100644
> > --- a/src/conf/domain_conf.c
> > +++ b/src/conf/domain_conf.c
> > @@ -2927,7 +2927,7 @@ virDomainObjGetDefs(virDomainObjPtr vm,
> >      if (liveDef)
> >          *liveDef = NULL;
> > 
> > -    if (*persDef)
> > +    if (persDef)
> >          *persDef = NULL;
> > 
> >      if (virDomainObjUpdateModificationImpact(vm, &flags) < 0)
> > 
> 
> 
> yes - this makes Coverity happy... Still curious about :
> 
> +    if (flags & VIR_DOMAIN_AFFECT_LIVE) {
> +        if (liveDef)
> +            *liveDef = vm->def;
> +
> +        if (persDef)
> +            *liveDef = vm->newDef;
> 
> 
> Coverity doesn't flag the second *liveDef setting, but from just reading
> the code it seems if NULL is passed for liveDef and something is passed
> for persDef, then we could run into an issue here deref'ing liveDef
> 

Yup, I didn't originally notice this in the previous mail. I've already
prepared a fix for this.

Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150604/bb5d654a/attachment-0001.sig>


More information about the libvir-list mailing list