[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 34/36] block: Fail bdrv_truncate() with negative
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH v2 34/36] block: Fail bdrv_truncate() with negative size |
Date: |
Wed, 21 Feb 2018 14:54:02 +0100 |
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 <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
block.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/block.c b/block.c
index 4a7e448226..5c874aefa1 100644
--- a/block.c
+++ b/block.c
@@ -3684,6 +3684,11 @@ int bdrv_truncate(BdrvChild *child, int64_t offset,
PreallocMode prealloc,
error_setg(errp, "No medium inserted");
return -ENOMEDIUM;
}
+ if (offset < 0) {
+ error_setg(errp, "Image size cannot be negative");
+ return -EINVAL;
+ }
+
if (!drv->bdrv_truncate) {
if (bs->file && drv->is_filter) {
return bdrv_truncate(bs->file, offset, prealloc, errp);
--
2.13.6
- Re: [Qemu-devel] [PATCH v2 27/36] sheepdog: QAPIfy "redundacy" create option, (continued)
- [Qemu-devel] [PATCH v2 28/36] sheepdog: Support .bdrv_co_create, Kevin Wolf, 2018/02/21
- [Qemu-devel] [PATCH v2 30/36] ssh: QAPIfy host-key-check option, Kevin Wolf, 2018/02/21
- [Qemu-devel] [PATCH v2 29/36] ssh: Use QAPI BlockdevOptionsSsh object, Kevin Wolf, 2018/02/21
- [Qemu-devel] [PATCH v2 32/36] ssh: Support .bdrv_co_create, Kevin Wolf, 2018/02/21
- [Qemu-devel] [PATCH v2 33/36] file-posix: Fix no-op bdrv_truncate() with falloc preallocation, Kevin Wolf, 2018/02/21
- [Qemu-devel] [PATCH v2 34/36] block: Fail bdrv_truncate() with negative size,
Kevin Wolf <=
- [Qemu-devel] [PATCH v2 31/36] ssh: Pass BlockdevOptionsSsh to connect_to_ssh(), Kevin Wolf, 2018/02/21
- [Qemu-devel] [PATCH v2 35/36] qemu-iotests: Test qcow2 over file image creation with QMP, Kevin Wolf, 2018/02/21
- [Qemu-devel] [PATCH v2 36/36] qemu-iotests: Test ssh image creation over QMP, Kevin Wolf, 2018/02/21