[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 35/37] block: Fail bdrv_truncate() with negative
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH v4 35/37] block: Fail bdrv_truncate() with negative size |
Date: |
Wed, 7 Mar 2018 19:59:44 +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] [PATCH v4 25/37] rbd: Use qemu_rbd_connect() in qemu_rbd_do_create(), (continued)
- [Qemu-devel] [PATCH v4 25/37] rbd: Use qemu_rbd_connect() in qemu_rbd_do_create(), Kevin Wolf, 2018/03/07
- [Qemu-devel] [PATCH v4 29/37] sheepdog: Support .bdrv_co_create, Kevin Wolf, 2018/03/07
- [Qemu-devel] [PATCH v4 33/37] ssh: Support .bdrv_co_create, Kevin Wolf, 2018/03/07
- [Qemu-devel] [PATCH v4 28/37] sheepdog: QAPIfy "redundancy" create option, Kevin Wolf, 2018/03/07
- [Qemu-devel] [PATCH v4 26/37] nfs: Use QAPI options in nfs_client_open(), Kevin Wolf, 2018/03/07
- [Qemu-devel] [PATCH v4 32/37] ssh: Pass BlockdevOptionsSsh to connect_to_ssh(), Kevin Wolf, 2018/03/07
- [Qemu-devel] [PATCH v4 34/37] file-posix: Fix no-op bdrv_truncate() with falloc preallocation, Kevin Wolf, 2018/03/07
- [Qemu-devel] [PATCH v4 31/37] ssh: QAPIfy host-key-check option, Kevin Wolf, 2018/03/07
- [Qemu-devel] [PATCH v4 30/37] ssh: Use QAPI BlockdevOptionsSsh object, Kevin Wolf, 2018/03/07
- [Qemu-devel] [PATCH v4 35/37] block: Fail bdrv_truncate() with negative size,
Kevin Wolf <=
- [Qemu-devel] [PATCH v4 37/37] qemu-iotests: Test ssh image creation over QMP, Kevin Wolf, 2018/03/07
- [Qemu-devel] [PATCH v4 36/37] qemu-iotests: Test qcow2 over file image creation with QMP, Kevin Wolf, 2018/03/07
- Re: [Qemu-devel] [PATCH v4 00/37] x-blockdev-create for protocols and qcow2, no-reply, 2018/03/07
- Re: [Qemu-devel] [PATCH v4 00/37] x-blockdev-create for protocols and qcow2, Daniel P . Berrangé, 2018/03/08