qemu-img: avoid overflow of min_sparse parameter
commit6360ab278cc1ac3e1235e0755e4cba1f918e6f3c
authorPeter Lieven <pl@kamp.de>
Fri, 13 Jul 2018 07:15:39 +0000 (13 09:15 +0200)
committerKevin Wolf <kwolf@redhat.com>
Mon, 23 Jul 2018 14:50:43 +0000 (23 16:50 +0200)
tree9f92ac840c9baa83e849040823e2e2dba5a71627
parent50d6a8a352af164a3335d510af38b9545d568676
qemu-img: avoid overflow of min_sparse parameter

the min_sparse convert parameter can overflow (e.g. -S 1024G)
in the conversion from int64_t to int resulting in a negative
min_sparse parameter. Avoid this by limiting the valid parameters
to sane values. In fact anything exceeding the convert buffer size
is also pointless. While at it also forbid values that are non
multiple of 512 to avoid undesired behaviour. For instance, values
between 1 and 511 were legal, but resulted in full allocation.

Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qemu-img.c