[libvirt] [PATCH] fix xenDaemonListDefinedDomains

Matthias Bolte matthias.bolte at googlemail.com
Wed Nov 25 00:54:05 UTC 2009


2009/11/25 Jim Fehlig <jfehlig at novell.com>:
> Commit 790f0b3057787bb64da8c46c111ff8d3eff7b2af causes contents of names
> array to be freed even on success, resulting in no listing of defined
> but inactive Xen domains. Patch below fixes it.
>
> Regards,
> Jim
>

Good catch, I just reviewed this commit to see if I've caused similar
bugs elsewhere, but this seems to be the only one.

> Index: libvirt-0.7.4/src/xen/xend_internal.c
> ===================================================================
> --- libvirt-0.7.4.orig/src/xen/xend_internal.c
> +++ libvirt-0.7.4/src/xen/xend_internal.c
> @@ -4693,13 +4693,14 @@ xenDaemonListDefinedDomains(virConnectPt
>          }
>
>          if (ret >= maxnames)
> -            break;
> +            goto out;
>      }
>
>  error:
>      for (i = 0; i < ret; ++i)
>          VIR_FREE(names[i]);
>
> +out:
>      sexpr_free(root);
>      return(ret);
>  }

Your patch doesn't fix the problem in all situations. If maxnames is
larger than the actual number of domains then goto out is never
executed.

I also forgot to set ret to -1 after freeing the names, this needs to
be fixed too.

I propose the attached patch to solve this issues.

Matthias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xen-list-defined_alternative-fix.diff
Type: text/x-diff
Size: 497 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20091125/db85e1c6/attachment-0001.bin>


More information about the libvir-list mailing list