[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 11/30] block: Don't copy backing file name on error
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 11/30] block: Don't copy backing file name on error |
Date: |
Thu, 31 Oct 2013 16:48:25 +0100 |
From: Max Reitz <address@hidden>
bdrv_open_backing_file() tries to copy the backing file name using
pstrcpy directly after calling bdrv_open() to open the backing file
without checking whether that was actually successful. If it was not,
ps->backing_hd->file will probably be NULL and qemu will crash.
Fix this by moving pstrcpy after checking whether bdrv_open() succeeded.
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Benoit Canet <address@hidden>
Reviewed-by: Amos Kong <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/block.c b/block.c
index fd05a80..366999b 100644
--- a/block.c
+++ b/block.c
@@ -1004,8 +1004,6 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict
*options, Error **errp)
ret = bdrv_open(bs->backing_hd,
*backing_filename ? backing_filename : NULL, options,
back_flags, back_drv, &local_err);
- pstrcpy(bs->backing_file, sizeof(bs->backing_file),
- bs->backing_hd->file->filename);
if (ret < 0) {
bdrv_unref(bs->backing_hd);
bs->backing_hd = NULL;
@@ -1013,6 +1011,8 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict
*options, Error **errp)
error_propagate(errp, local_err);
return ret;
}
+ pstrcpy(bs->backing_file, sizeof(bs->backing_file),
+ bs->backing_hd->file->filename);
return 0;
}
--
1.8.1.4
- [Qemu-devel] [PULL v2 00/30] Block patches, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 02/30] qcow2: Restore total_sectors value in save_vmstate, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 04/30] qemu-img: add special exit code if bdrv_check is not supported, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 05/30] block/vpc: check that the image has not been truncated, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 01/30] qapi: fix documentation example, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 03/30] qcow2: Unset zero_beyond_eof in save_vmstate, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 06/30] qemu-iotests: Test for loading VM state from qcow2, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 07/30] qcow2: Flush image after creation, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 09/30] ide-test: Check what happens with bus mastering disabled, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 10/30] tests: Multiboot mmap test case, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 11/30] block: Don't copy backing file name on error,
Kevin Wolf <=
- [Qemu-devel] [PULL 08/30] exec: Fix bounce buffer allocation in address_space_map(), Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 12/30] sheepdog: explicitly set copies as type uint8_t, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 14/30] ahci: fix win7 hang on boot, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 13/30] sheepdog: pass copy_policy in the request, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 15/30] block: Disable BDRV_O_COPY_ON_READ for the backing file, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 16/30] block: Avoid unecessary drv->bdrv_getlength() calls, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 17/30] qemu-iotests: Fix 051 reference output, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 18/30] qemu-iotests: drop duplicated "create_image", Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 19/30] qemu-iotests: Test case for backing file deletion, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 20/30] sheepdog: check return values of qemu_co_recv/send correctly, Kevin Wolf, 2013/10/31