]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block: Make find_image_format safe with NULL filename
authorKevin Wolf <kwolf@redhat.com>
Mon, 18 Mar 2013 15:20:27 +0000 (16:20 +0100)
committerKevin Wolf <kwolf@redhat.com>
Fri, 22 Mar 2013 16:51:32 +0000 (17:51 +0100)
In order to achieve this, the .bdrv_probe callbacks of all drivers must
cope with this. The DMG driver is the only one that bases its decision
on the filename and it needs to be changed.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
block/dmg.c

index c1066df13a369b40d08cf54729e51edb5d71939e..3141cb5b889a4972eb40a3e09e761cac85db2bfa 100644 (file)
@@ -51,9 +51,16 @@ typedef struct BDRVDMGState {
 
 static int dmg_probe(const uint8_t *buf, int buf_size, const char *filename)
 {
-    int len=strlen(filename);
-    if(len>4 && !strcmp(filename+len-4,".dmg"))
-       return 2;
+    int len;
+
+    if (!filename) {
+        return 0;
+    }
+
+    len = strlen(filename);
+    if (len > 4 && !strcmp(filename + len - 4, ".dmg")) {
+        return 2;
+    }
     return 0;
 }