[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] block/curl: Improve type safety of s->timeout.
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH] block/curl: Improve type safety of s->timeout. |
Date: |
Tue, 28 Oct 2014 14:29:20 +0000 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Mon, Oct 06, 2014 at 03:32:10PM +0100, Richard W.M. Jones wrote:
> qemu_opt_get_number returns a uint64_t, and curl_easy_setopt expects a
> long (not an int).
>
> Store the timeout (which is a positive number of seconds) as a
> uint64_t. Check that the number given by the user is reasonable.
> Cast it to long before calling curl_easy_setopt.
>
> Example error message after this change has been applied:
>
> $ ./qemu-img create -f qcow2 /tmp/test.qcow2 \
> -b 'json: { "file.driver":"https",
> "file.url":"https://foo/bar",
> "file.timeout":-1 }'
> qemu-img: /tmp/test.qcow2: Could not open 'json: { "file.driver":"https",
> "file.url":"https://foo/bar", "file.timeout":-1 }': timeout parameter is too
> large or negative: Invalid argument
>
> Signed-off-by: Richard W.M. Jones <address@hidden>
> ---
> block/curl.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block
Stefan
pgpp4UqMfkChT.pgp
Description: PGP signature