On 1/15/19 6:31 AM, Vladimir Sementsov-Ogievskiy wrote: > 12.01.2019 20:57, Eric Blake wrote: >> Our copy-and-pasted open-coding of strtol handling forgot to >> handle overflow conditions. Use qemu_strto*() instead. >> >> In the case of --partition, since we insist on a user-supplied >> partition to be non-zero, we can use 0 rather than -1 for our >> initial value to distinguish when a partition is not being >> served, for slightly more optimal code. >> >> The error messages for out-of-bounds values are less specific, >> but should not be a terrible loss in quality. >> >> Signed-off-by: Eric Blake <[email protected]> >> Message-Id: <[email protected]> >>
>> - if (partition < 1 || partition > 8) {
>> - error_report("Invalid partition %d", partition);
>> + if (qemu_strtoi(optarg, NULL, 0, &partition) < 0 ||
>
> we can use unsigned conversion like for offset (and unsigned type for
> partition), but this doesn't really matter.
Yes, but I didn't see the point in changing the variable types in this
patch.
>
> anyway,
> Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
