Patchwork [17/24] block/vdi: Check for bad signature

login
register
mail settings
Submitter Kevin Wolf
Date Jan. 25, 2013, 6:45 p.m.
Message ID <1359139560-15387-18-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/215843/
State New
Headers show

Comments

Kevin Wolf - Jan. 25, 2013, 6:45 p.m.
From: Stefan Weil <sw@weilnetz.de>

vdi_open did not check for a bad signature.
This check was only in vdi_probe.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/vdi.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

Patch

diff --git a/block/vdi.c b/block/vdi.c
index 8b768bf..257a592 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -392,7 +392,11 @@  static int vdi_open(BlockDriverState *bs, int flags)
         header.disk_size &= ~(SECTOR_SIZE - 1);
     }
 
-    if (header.version != VDI_VERSION_1_1) {
+    if (header.signature != VDI_SIGNATURE) {
+        logout("bad vdi signature %08x\n", header.signature);
+        ret = -EMEDIUMTYPE;
+        goto fail;
+    } else if (header.version != VDI_VERSION_1_1) {
         logout("unsupported version %u.%u\n",
                header.version >> 16, header.version & 0xffff);
         ret = -ENOTSUP;