block/vpc: Add a sanity check that fixed-size images have the right type
PATCH 1/1 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.
--- block/vpc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
block/vpc.c +2 -1
@@ -286,7 +286,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;
Signature · 1 line
2.27.0
Hanna Reitz
AppliedQuoted 11 lines · Thomas Huth
The code in
vpc.cusesBDRVVPCState->footer.typein 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 containsVHD_FIXEDif we detected a fixed size image invpc_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]>--- block/vpc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Thanks, applied to my block branch:
https://gitlab.com/hreitz/qemu/-/commits/block/
Hanna