[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 17/40] vmdk: Switch to heap arrays for vmdk_parent_op
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 17/40] vmdk: Switch to heap arrays for vmdk_parent_open |
Date: |
Mon, 14 Mar 2016 18:37:18 +0100 |
From: Fam Zheng <address@hidden>
Signed-off-by: Fam Zheng <address@hidden>
Reviewed-by: Paolo Bonzini <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/vmdk.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/block/vmdk.c b/block/vmdk.c
index c68f456..03be7f0 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -343,15 +343,16 @@ static int vmdk_reopen_prepare(BDRVReopenState *state,
static int vmdk_parent_open(BlockDriverState *bs)
{
char *p_name;
- char desc[DESC_SIZE + 1];
+ char *desc;
BDRVVmdkState *s = bs->opaque;
int ret;
- desc[DESC_SIZE] = '\0';
+ desc = g_malloc0(DESC_SIZE + 1);
ret = bdrv_pread(bs->file->bs, s->desc_offset, desc, DESC_SIZE);
if (ret < 0) {
- return ret;
+ goto out;
}
+ ret = 0;
p_name = strstr(desc, "parentFileNameHint");
if (p_name != NULL) {
@@ -360,16 +361,20 @@ static int vmdk_parent_open(BlockDriverState *bs)
p_name += sizeof("parentFileNameHint") + 1;
end_name = strchr(p_name, '\"');
if (end_name == NULL) {
- return -EINVAL;
+ ret = -EINVAL;
+ goto out;
}
if ((end_name - p_name) > sizeof(bs->backing_file) - 1) {
- return -EINVAL;
+ ret = -EINVAL;
+ goto out;
}
pstrcpy(bs->backing_file, end_name - p_name + 1, p_name);
}
- return 0;
+out:
+ g_free(desc);
+ return ret;
}
/* Create and append extent to the extent array. Return the added VmdkExtent
--
1.8.3.1
- [Qemu-block] [PULL 06/40] block/vpc: tests for auto-detecting VPC and Hyper-V VHD images, (continued)
- [Qemu-block] [PULL 06/40] block/vpc: tests for auto-detecting VPC and Hyper-V VHD images, Kevin Wolf, 2016/03/14
- [Qemu-block] [PULL 07/40] block/vpc: give option to force the current_size field in .bdrv_create, Kevin Wolf, 2016/03/14
- [Qemu-block] [PULL 09/40] docs: fix invalid node name in qmp event, Kevin Wolf, 2016/03/14
- [Qemu-block] [PULL 10/40] qmp event: Refactor QUORUM_REPORT_BAD, Kevin Wolf, 2016/03/14
- [Qemu-block] [PULL 12/40] blockdev: Snapshotting must not open second instance of old top, Kevin Wolf, 2016/03/14
- [Qemu-block] [PULL 11/40] quorum: modify vote rules for flush operation, Kevin Wolf, 2016/03/14
- [Qemu-block] [PULL 13/40] block: Fix snapshot=on cache modes, Kevin Wolf, 2016/03/14
- [Qemu-block] [PULL 14/40] block: Fix cache mode defaults in bds_tree_init(), Kevin Wolf, 2016/03/14
- [Qemu-block] [PULL 15/40] vmdk: Switch to heap arrays for vmdk_write_cid, Kevin Wolf, 2016/03/14
- [Qemu-block] [PULL 16/40] vmdk: Switch to heap arrays for vmdk_read_cid, Kevin Wolf, 2016/03/14
- [Qemu-block] [PULL 17/40] vmdk: Switch to heap arrays for vmdk_parent_open,
Kevin Wolf <=
- [Qemu-block] [PULL 19/40] hmp: Extend drive_del to delete nodes without BB, Kevin Wolf, 2016/03/14
- [Qemu-block] [PULL 22/40] parallels: Use BB functions in .bdrv_create(), Kevin Wolf, 2016/03/14
- [Qemu-block] [PULL 20/40] block: Use writeback in .bdrv_create() implementations, Kevin Wolf, 2016/03/14
- [Qemu-block] [PULL 21/40] block: Introduce blk_set_allow_write_beyond_eof(), Kevin Wolf, 2016/03/14
- [Qemu-block] [PULL 18/40] hmp: 'drive_add -n' for creating a node without BB, Kevin Wolf, 2016/03/14
- [Qemu-block] [PULL 23/40] qcow: Use BB functions in .bdrv_create(), Kevin Wolf, 2016/03/14
- [Qemu-block] [PULL 24/40] qcow2: Use BB functions in .bdrv_create(), Kevin Wolf, 2016/03/14
- [Qemu-block] [PULL 25/40] qed: Use BB functions in .bdrv_create(), Kevin Wolf, 2016/03/14