Skip to content

Commit

Permalink
block/vpc: Add a sanity check that fixed-size images have the right type
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Hanna Reitz <[email protected]>
  • Loading branch information
huth authored and XanClic committed Nov 2, 2021
1 parent f3d43df commit 7da9623
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion block/vpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7da9623

Please sign in to comment.