From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42179) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjIgR-0002d7-At for qemu-devel@nongnu.org; Tue, 28 Oct 2014 22:08:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XjIgN-0000lI-0a for qemu-devel@nongnu.org; Tue, 28 Oct 2014 22:08:23 -0400 Received: from szxga01-in.huawei.com ([119.145.14.64]:36084) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjIgM-0000ku-Cn for qemu-devel@nongnu.org; Tue, 28 Oct 2014 22:08:18 -0400 Message-ID: <54504C07.4080707@huawei.com> Date: Wed, 29 Oct 2014 10:08:07 +0800 From: Gonglei MIME-Version: 1.0 References: <1412605930-3397-1-git-send-email-rjones@redhat.com> <20141028142920.GD22805@stefanha-thinkpad.redhat.com> In-Reply-To: <20141028142920.GD22805@stefanha-thinkpad.redhat.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] block/curl: Improve type safety of s->timeout. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: kwolf@redhat.com, lersek@redhat.com, "Richard W.M. Jones" , stefanha@redhat.com, qemu-devel@nongnu.org On 2014/10/28 22:29, Stefan Hajnoczi wrote: > 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 >> --- >> 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 Please don't, the patch had been posted v2 which is better: [PATCH v2] block/curl: Improve type safety of s->timeout. http://lists.gnu.org/archive/html/qemu-devel/2014-10/msg03112.html Best regards, -Gonglei