From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UINvt-0002UY-NU for qemu-devel@nongnu.org; Wed, 20 Mar 2013 14:40:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UINvs-0004JG-6g for qemu-devel@nongnu.org; Wed, 20 Mar 2013 14:40:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26166) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UINvr-0004JB-V9 for qemu-devel@nongnu.org; Wed, 20 Mar 2013 14:40:16 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2KIeFOP032461 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 20 Mar 2013 14:40:15 -0400 From: Kevin Wolf Date: Wed, 20 Mar 2013 19:39:45 +0100 Message-Id: <1363804788-18535-10-git-send-email-kwolf@redhat.com> In-Reply-To: <1363804788-18535-1-git-send-email-kwolf@redhat.com> References: <1363804788-18535-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH v2 09/12] block: Make find_image_format safe with NULL filename List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com 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 Reviewed-by: Eric Blake --- block/dmg.c | 13 ++++++++++--- 1 file 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; } -- 1.8.1.4