[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 4/7] qcow2: Check failure of bdrv_getlength()
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 4/7] qcow2: Check failure of bdrv_getlength() |
Date: |
Fri, 11 Aug 2017 16:05:33 +0200 |
From: Eric Blake <address@hidden>
qcow2_co_pwritev_compressed() should not call bdrv_truncate()
if determining the size failed.
Reported-by: Markus Armbruster <address@hidden>
Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Jeff Cody <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Reviewed-by: John Snow <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow2.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index 99407403ea..40ba26c111 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -3282,12 +3282,15 @@ qcow2_co_pwritev_compressed(BlockDriverState *bs,
uint64_t offset,
z_stream strm;
int ret, out_len;
uint8_t *buf, *out_buf;
- uint64_t cluster_offset;
+ int64_t cluster_offset;
if (bytes == 0) {
/* align end of file to a sector boundary to ease reading with
sector based I/Os */
cluster_offset = bdrv_getlength(bs->file->bs);
+ if (cluster_offset < 0) {
+ return cluster_offset;
+ }
return bdrv_truncate(bs->file, cluster_offset, PREALLOC_MODE_OFF,
NULL);
}
--
2.13.4
- [Qemu-devel] [PULL 0/7] Block/Multiboot patches for 2.10.0-rc3, Kevin Wolf, 2017/08/11
- [Qemu-devel] [PULL 1/7] tests/multiboot: Fix whitespace failure, Kevin Wolf, 2017/08/11
- [Qemu-devel] [PULL 2/7] vpc: Check failure of bdrv_getlength(), Kevin Wolf, 2017/08/11
- [Qemu-devel] [PULL 4/7] qcow2: Check failure of bdrv_getlength(),
Kevin Wolf <=
- [Qemu-devel] [PULL 5/7] osdep: Add runtime OFD lock detection, Kevin Wolf, 2017/08/11
- [Qemu-devel] [PULL 6/7] file-posix: Do runtime check for ofd lock API, Kevin Wolf, 2017/08/11
- [Qemu-devel] [PULL 3/7] qcow2: Drop debugging dump_refcounts(), Kevin Wolf, 2017/08/11
- [Qemu-devel] [PULL 7/7] qemu-iotests: fix 185, Kevin Wolf, 2017/08/11
- Re: [Qemu-devel] [PULL 0/7] Block/Multiboot patches for 2.10.0-rc3, Peter Maydell, 2017/08/11