qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eyal Moscovici <eyal.moscovici@oracle.com>
To: Eric Blake <eblake@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	liran.alon@oracle.com, qemu-devel@nongnu.org,
	qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: Re: [PATCH v2 1/5] qemu-img: remove check that cvtnum value > MAX_INT
Date: Tue, 12 May 2020 12:39:18 +0300	[thread overview]
Message-ID: <d136e935-d8af-1710-c1c4-5bc6bc3b9303@oracle.com> (raw)
In-Reply-To: <f4131818-f606-2b30-ef69-d9612fb66a80@redhat.com>


On 07/05/2020 0:49, Eric Blake wrote:
> On 5/6/20 4:34 PM, Eyal Moscovici wrote:
>> Following commit f46bfdbfc8f95cf65d7818ef68a801e063c40332 
>> (util/cutils: Change
>> qemu_strtosz*() from int64_t to uint64_t) which added a similar check to
>> cvtnum. As a result there is no need to check it separately outside 
>> of cvtnum.
>>
>> Acked-by: Mark Kanda <mark.kanda@oracle.com>
>> Signed-off-by: Eyal Moscovici <eyal.moscovici@oracle.com>
>> ---
>>   qemu-img.c | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/qemu-img.c b/qemu-img.c
>> index 6a4327aaba..116a9c6349 100644
>> --- a/qemu-img.c
>> +++ b/qemu-img.c
>> @@ -4307,7 +4307,7 @@ static int img_bench(int argc, char **argv)
>>               int64_t sval;
>>                 sval = cvtnum(optarg);
>> -            if (sval < 0 || sval > INT_MAX) {
>> +            if (sval < 0) {
>>                   error_report("Invalid buffer size specified");
>
> INT_MAX is smaller than cvtnum's check for INT64_MAX.  This code 
> change allows larger buffer sizes, which is probably not a good idea.
I was the most hesitant about this patch because of the size difference. 
I decided to submit it because the type is int64 which pairs better with 
the MAX_INT64 check and I couldn't find a concrete reason to cap the 
variable at MAX_INT. Do you a concrete reason? Because the max size 
should rerally come into effect on very fringe cases and if you are 
asking for a really big buffer you should know the risks.
>
>>                   return 1;
>>               }
>> @@ -4320,7 +4320,7 @@ static int img_bench(int argc, char **argv)
>>               int64_t sval;
>>                 sval = cvtnum(optarg);
>> -            if (sval < 0 || sval > INT_MAX) {
>> +            if (sval < 0) {
>>                   error_report("Invalid step size specified");
>>                   return 1;
>>               }
>> @@ -4493,7 +4493,7 @@ static int img_dd_bs(const char *arg,
>>         res = cvtnum(arg);
>>   -    if (res <= 0 || res > INT_MAX) {
>> +    if (res <= 0) {
>>           error_report("invalid number: '%s'", arg);
>>           return 1;
>>       }
>>
>
> NACK.
>


  reply	other threads:[~2020-05-12  9:42 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-22  9:11 [PATCH 0/2] Additional parameters for qemu_img map Eyal Moscovici
2020-03-22  9:11 ` [PATCH 1/2] qemu-img: refactor dump_map_entry JSON format output Eyal Moscovici
2020-04-29 14:58   ` Eric Blake
2020-05-06  9:55     ` Eyal Moscovici
2020-03-22  9:11 ` [PATCH 2/2] qemu-img: Add --start-offset and --max-length to map Eyal Moscovici
2020-04-29 15:04   ` Eric Blake
2020-05-06  9:52     ` Eyal Moscovici
2020-04-29 13:39 ` [PATCH 0/2] Additional parameters for qemu_img map John Snow
2020-05-06 21:34   ` [PATCH v2 0/5] " Eyal Moscovici
2020-05-06 21:34     ` [PATCH v2 1/5] qemu-img: remove check that cvtnum value > MAX_INT Eyal Moscovici
2020-05-06 21:49       ` Eric Blake
2020-05-12  9:39         ` Eyal Moscovici [this message]
2020-05-12 14:14           ` Eric Blake
2020-05-06 21:34     ` [PATCH v2 2/5] qemu_img: add error report to cvtnum Eyal Moscovici
2020-05-06 21:59       ` Eric Blake
2020-05-12  9:44         ` Eyal Moscovici
2020-05-06 21:34     ` [PATCH v2 3/5] qemu-img: validate image length in img_map Eyal Moscovici
2020-05-06 22:01       ` Eric Blake
2020-05-06 21:34     ` [PATCH v2 4/5] qemu-img: refactor dump_map_entry JSON format output Eyal Moscovici
2020-05-06 21:34     ` [PATCH v2 5/5] qemu-img: Add --start-offset and --max-length to map Eyal Moscovici
2020-05-06 22:04       ` Eric Blake
2020-05-12  9:48         ` Eyal Moscovici
2020-05-06 21:45     ` [PATCH v2 0/5] Additional parameters for qemu_img map Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d136e935-d8af-1710-c1c4-5bc6bc3b9303@oracle.com \
    --to=eyal.moscovici@oracle.com \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=liran.alon@oracle.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).