Re: [PATCH 2/2] nwfilter: address more coverity findings

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

 



On 04/26/2012 01:46 PM, Stefan Berger wrote:
> This patch addresses the following coverity findings:
> 
> /libvirt/src/conf/nwfilter_params.c:390:
> var_assigned: Assigning: "varValue" = null return value from
> "virHashLookup".
> 
> /libvirt/src/conf/nwfilter_params.c:392:
> dereference: Dereferencing a pointer that might be null "varValue" when
> calling "virNWFilterVarValueGetNthValue".
> 
> /libvirt/src/conf/nwfilter_params.c:399:
> dereference: Dereferencing a pointer that might be null "tmp" when
> calling "virNWFilterVarValueGetNthValue".
> 
> ---
>  src/conf/nwfilter_params.c |   16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)

Nice to have tools that help us catch bugs.

> @@ -391,14 +391,28 @@ virNWFilterVarCombIterEntryAreUniqueEntr
>      const char *value;
> 
>      varValue = virHashLookup(hash->hashTable, cie->varNames[0]);
> +    if (!varValue) {
> +        /* caller's error */
> +        VIR_ERROR(_("%s: hash lookup resulted in NULL pointer"),
> __func__);

VIR_ERROR already appends __func__ to the resulting message.  This
should be:

VIR_ERROR("%s", _("hash lookup resulted in NULL pointer"));

> 
>      value = virNWFilterVarValueGetNthValue(varValue, cie->curValue);
> +    if (!value) {
> +        VIR_ERROR(_("%s: Lookup of value at index %u resulted in a NULL "
> +                  "pointer"), __func__, cie->curValue);

And again, this should be:

VIR_ERROR(_("Lookup of value at index %u resulted in a NULL pointer"),
          cie->curValue);

ACK with those fixes; I'm okay if you push without posting a v2.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]