On Thu, Aug 04, 2016 at 09:47:45 +0200, Michal Privoznik wrote:
> The virJSONValueArraySize() function return ssize_t (with
> possibly returning -1 if the passed json is not an array).
> Storing the return value into size_t is possibly dangerous then.

Not in this case. All code paths calling this function guarantee that
the JSON object is an array, so it won't ever be negative.

Don't trust anything that coverity tells you.

> 
> Signed-off-by: Michal Privoznik <mpriv...@redhat.com>
> ---
>  src/util/virqemu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/util/virqemu.c b/src/util/virqemu.c
> index a1ba562..0b516fc 100644
> --- a/src/util/virqemu.c
> +++ b/src/util/virqemu.c
> @@ -85,7 +85,7 @@ virQEMUBuildCommandLineJSONArrayNumbered(const char *key,
>                                           virBufferPtr buf)
>  {
>      const virJSONValue *member;
> -    size_t nelems = virJSONValueArraySize(array);
> +    ssize_t nelems = virJSONValueArraySize(array);

ACK if you remove the hint that it could cause a problem from the commit
message. 

Peter

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

Reply via email to