[libvirt] [PATCH v2 3/6] libxl: Resolve Coverity FORWARD_NULL

Peter Krempa pkrempa at redhat.com
Wed Oct 7 06:19:26 UTC 2015


On Fri, Sep 25, 2015 at 12:31:42 -0400, John Ferlan wrote:
> Since the strtok_r call in libxlCapsInitGuests expects a non NULL first
> parameter when the third parameter is NULL, we need to check that
> the returned 'capabilities' from a libxl_get_version_info call is
> not NULL and error out if so since the code expects it.

According to the source of the function that fills ver_info

http://fossies.org/dox/xen-4.5.1/libxl_8c_source.html#l05266

the "capabilities" member is filled via strdup and not checked, so this
makes sense. Btw, few of the other fields have the same issue too, but
none of those is used in this function.

> 
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  src/libxl/libxl_conf.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
> index 35fd495..4eed5ca 100644
> --- a/src/libxl/libxl_conf.c
> +++ b/src/libxl/libxl_conf.c
> @@ -319,6 +319,12 @@ libxlCapsInitGuests(libxl_ctx *ctx, virCapsPtr caps)
>          return -1;
>      }
>  
> +    if (!ver_info->capabilities) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                       _("Failed to get capabilities from libxenlight"));
> +        return -1;
> +    }
> +

ACK,

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/20151007/516b9701/attachment-0001.sig>


More information about the libvir-list mailing list