diff options
author | Kevin Wolf <kwolf@redhat.com> | 2013-03-18 16:20:27 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2013-03-22 17:51:32 +0100 |
commit | f5866fa438bff586f215c137dc71edb4e0770536 (patch) | |
tree | 693536fcf30715668dd6f4962ea3a839ad018e1e /block/dmg.c | |
parent | 08b392e1510b21d8c9bfa8a50525fae31014a2e2 (diff) | |
download | qemu-f5866fa438bff586f215c137dc71edb4e0770536.zip qemu-f5866fa438bff586f215c137dc71edb4e0770536.tar.gz qemu-f5866fa438bff586f215c137dc71edb4e0770536.tar.bz2 |
block: Make find_image_format safe with NULL filename
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>
Diffstat (limited to 'block/dmg.c')
-rw-r--r-- | block/dmg.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/block/dmg.c b/block/dmg.c index c1066df..3141cb5 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -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; } |