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

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



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


Attachment: signature.asc
Description: OpenPGP digital signature


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