qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block/vpc: Add a sanity check that fixed-size images have the right type
@ 2021-10-12  8:27 Thomas Huth
  2021-10-13  9:52 ` Hanna Reitz
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Huth @ 2021-10-12  8:27 UTC (permalink / raw)
  To: qemu-block, Kevin Wolf; +Cc: Hanna Reitz, qemu-devel

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>
---
 block/vpc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/block/vpc.c b/block/vpc.c
index dc0ad9fcdc..ec55d69360 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -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;
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-13  9:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-12  8:27 [PATCH] block/vpc: Add a sanity check that fixed-size images have the right type Thomas Huth
2021-10-13  9:52 ` Hanna Reitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).