blockdev: Error out on negative throttling option values
commit972606c4db826f286f7f475551180502859f49b9
authorFam Zheng <famz@redhat.com>
Wed, 20 Jan 2016 04:21:20 +0000 (20 12:21 +0800)
committerKevin Wolf <kwolf@redhat.com>
Wed, 20 Jan 2016 12:37:37 +0000 (20 13:37 +0100)
tree125805ef1ec52a3c930a1c5e900c76410e92b4be
parentd62d9dc4b814950dcc8bd261a3e2e9300d9065e6
blockdev: Error out on negative throttling option values

extract_common_blockdev_options() uses qemu_opt_get_number() to parse
the bps/iops numbers to uint64_t, then converts to double and stores in
ThrottleConfig.  The actual parsing is done by strtoull() in
parse_option_number().  Negative numbers are wrapped to large positive
ones, and stored.

We used to reject negative numbers since 7d81c1413c9, but this regressed
when the option parsing code was changed later. Now fix this again.

This time, define an arbitrary large upper limit (1e15),  and check the
values so both negative and impractically big numbers are caught and
reported.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
blockdev.c
include/qemu/throttle.h
util/throttle.c