[Libguestfs] [PATCH] Fix lossy conversion of Content-Length

Eric Blake eblake at redhat.com
Wed Jan 8 13:19:56 UTC 2020


On 1/7/20 4:13 AM, Adrian Ambrożewicz wrote:
> Actual variable holding content length is int64_t, but it was assigned
> by explicit cast to size_t. On 32-bit systems it's a lossy conversion,
> so it was replaced by casting to int64_t instead.
> 
> Signed-off-by: Adrian Ambrożewicz <adrian.ambrozewicz at linux.intel.com>
> ---
>   plugins/curl/curl.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/plugins/curl/curl.c b/plugins/curl/curl.c
> index 031bd32..fe1330e 100644
> --- a/plugins/curl/curl.c
> +++ b/plugins/curl/curl.c
> @@ -389,7 +389,7 @@ curl_open (int readonly)
>       goto err;
>     }
> 
> -  h->exportsize = (size_t) d;
> +  h->exportsize = (int64_t) d;

Why is a cast needed at all?  This is C, an implicit conversion works 
just as well.

>     nbdkit_debug ("content length: %" PRIi64, h->exportsize);
> 
>     if (strncasecmp (url, "http://", strlen ("http://")) == 0 ||

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




More information about the Libguestfs mailing list