[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 49/56] block: Fail bdrv_truncate() with negative size
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 49/56] block: Fail bdrv_truncate() with negative size |
Date: |
Fri, 9 Mar 2018 17:19:26 +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>
Reviewed-by: Eric Blake <address@hidden>
---
block.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/block.c b/block.c
index 00f94241fc..75a9fd49de 100644
--- a/block.c
+++ b/block.c
@@ -3719,6 +3719,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
- [Qemu-devel] [PULL 34/56] rbd: Factor out qemu_rbd_connect(), (continued)
- [Qemu-devel] [PULL 34/56] rbd: Factor out qemu_rbd_connect(), Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 36/56] rbd: Pass BlockdevOptionsRbd to qemu_rbd_connect(), Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 23/56] util: Add qemu_opts_to_qdict_filtered(), Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 31/56] file-win32: Support .bdrv_co_create, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 33/56] rbd: Fix use after free in qemu_rbd_set_keypairs() error path, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 37/56] rbd: Support .bdrv_co_create, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 40/56] nfs: Use QAPI options in nfs_client_open(), Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 48/56] file-posix: Fix no-op bdrv_truncate() with falloc preallocation, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 41/56] nfs: Support .bdrv_co_create, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 46/56] ssh: Pass BlockdevOptionsSsh to connect_to_ssh(), Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 49/56] block: Fail bdrv_truncate() with negative size,
Kevin Wolf <=
- [Qemu-devel] [PULL 44/56] ssh: Use QAPI BlockdevOptionsSsh object, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 39/56] rbd: Use qemu_rbd_connect() in qemu_rbd_do_create(), Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 35/56] rbd: Remove non-schema options from runtime_opts, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 43/56] sheepdog: Support .bdrv_co_create, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 51/56] qemu-iotests: Test ssh image creation over QMP, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 38/56] rbd: Assign s->snap/image_name in qemu_rbd_open(), Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 42/56] sheepdog: QAPIfy "redundancy" create option, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 47/56] ssh: Support .bdrv_co_create, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 45/56] ssh: QAPIfy host-key-check option, Kevin Wolf, 2018/03/09
- [Qemu-devel] [PULL 52/56] iotests: Test creating overlay when guest running, Kevin Wolf, 2018/03/09