[libvirt] [PATCH] Fix libvirtd crash when removing metadata

Peter Krempa pkrempa at redhat.com
Thu Sep 18 12:40:31 UTC 2014


On 09/18/14 14:25, Erik Skultety wrote:
> When trying to remove nonexistent metadata from XML, libvirt daemon
> crashes due to dereferencing NULL pointer.
> 
> Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1143955
> ---
>  src/util/virxml.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/util/virxml.c b/src/util/virxml.c
> index a91da05..f386956 100644
> --- a/src/util/virxml.c
> +++ b/src/util/virxml.c
> @@ -972,7 +972,9 @@ xmlNodePtr
>  virXMLFindChildNodeByNs(xmlNodePtr root,
>                          const char *uri)
>  {
> -    xmlNodePtr next;
> +    xmlNodePtr next = NULL;
> +    if (!root)
> +        goto cleanup;

You can return NULL right away

>  
>      for (next = root->children; next; next = next->next) {
>          if (next->ns &&
> @@ -980,6 +982,7 @@ virXMLFindChildNodeByNs(xmlNodePtr root,
>              return next;
>      }
>  
> + cleanup:

and don't bother with adding a label.

>      return NULL;
>  }
>  
> 

I'll push this shortly without the unnecessary label.

Peter


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


More information about the libvir-list mailing list