aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2021-10-12 10:27:02 +0200
committerHanna Reitz <hreitz@redhat.com>2021-11-02 12:47:51 +0100
commit7da9623cc078229caf07c290e16401ccdb9408d2 (patch)
tree8449963059375c2587cf31aa6dab43d893816339 /block
parentf3d43dfd9a8a870160f0aaf7bd692b9ce4827ead (diff)
downloadqemu-7da9623cc078229caf07c290e16401ccdb9408d2.zip
qemu-7da9623cc078229caf07c290e16401ccdb9408d2.tar.gz
qemu-7da9623cc078229caf07c290e16401ccdb9408d2.tar.bz2
block/vpc: Add a sanity check that fixed-size images have the right type
The code in vpc.c uses BDRVVPCState->footer.type in various places to decide whether the image is a fixed-size (VHD_FIXED) or a dynamic (VHD_DYNAMIC) image. However, we never check that this field really contains VHD_FIXED if we detected a fixed size image in vpc_open(), so a wrong value here could cause quite some trouble during runtime. Suggested-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com> Message-Id: <20211012082702.792259-1-thuth@redhat.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/vpc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/block/vpc.c b/block/vpc.c
index 1b4c733..297a262 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -276,7 +276,8 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,
if (ret < 0) {
goto fail;
}
- if (strncmp(footer->creator, "conectix", 8)) {
+ if (strncmp(footer->creator, "conectix", 8) ||
+ be32_to_cpu(footer->type) != VHD_FIXED) {
error_setg(errp, "invalid VPC image");
ret = -EINVAL;
goto fail;