[libvirt] [PATCH] virsh: reject negative values for scaled integer

Eric Blake eblake at redhat.com
Fri May 22 19:07:31 UTC 2015


On 05/22/2015 08:01 AM, Pavel Hrdina wrote:
> Some virsh commands have a size parameter, which is handled as scaled
> integer.  We don't have any *feature* that would allow to use '-1' as
> maximum size, so it's safe to reject any negative values for those
> commands.
> 
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1159171
> 
> Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
> ---
>  tools/virsh.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

ACK, particularly since it gets hard to justify whether -1M and -1G
would mean the same "maximum size".

> 
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 4425774..1005ba8 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -1811,7 +1811,7 @@ vshCommandOptScaledInt(const vshCmd *cmd, const char *name,
>      ret = vshCommandOptString(cmd, name, &str);
>      if (ret <= 0)
>          return ret;
> -    if (virStrToLong_ull(str, &end, 10, value) < 0 ||
> +    if (virStrToLong_ullp(str, &end, 10, value) < 0 ||
>          virScaleInteger(value, end, scale, max) < 0)
>          return -1;
>      return 1;
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150522/8878418b/attachment-0001.sig>


More information about the libvir-list mailing list