OSDN Git Service

block: Fail bdrv_truncate() with negative size
authorKevin Wolf <kwolf@redhat.com>
Wed, 7 Feb 2018 16:58:47 +0000 (17:58 +0100)
committerKevin Wolf <kwolf@redhat.com>
Fri, 9 Mar 2018 14:17:48 +0000 (15:17 +0100)
commitcd8b7aaa073d83337dd100f6258a56fdd76d778d
treeb47d7bc0c14631b96aee845966c3400aa9856016
parent89b259eeaa0f4ad3fa89cbe500da9335536e20ee
block: Fail bdrv_truncate() with negative size

Most callers have their own checks, but something like this should also
be checked centrally. As it happens, x-blockdev-create can pass negative
image sizes to format drivers (because there is no QAPI type that would
reject negative numbers) and triggers the check added by this patch.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
block.c