From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:59812) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1Hbl-0006hU-3o for qemu-devel@nongnu.org; Fri, 01 Feb 2013 09:28:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U1Hbe-0000fU-Tw for qemu-devel@nongnu.org; Fri, 01 Feb 2013 09:28:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60998) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1Hbe-0000fK-LI for qemu-devel@nongnu.org; Fri, 01 Feb 2013 09:28:42 -0500 From: Stefan Hajnoczi Date: Fri, 1 Feb 2013 15:28:03 +0100 Message-Id: <1359728884-19422-13-git-send-email-stefanha@redhat.com> In-Reply-To: <1359728884-19422-1-git-send-email-stefanha@redhat.com> References: <1359728884-19422-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH 12/13] vmdk: Allow space in file name List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori , Stefan Hajnoczi , Philipp Hahn From: Philipp Hahn The previous scanf() format string stopped parsing the file name on the first white white space, which seems to be allowed at least by VMware Workstation. Change the format string to collect everything between the first and second quote as the file name, disallowing line breaks. Signed-off-by: Philipp Hahn Reviewed-by: Markus Armbruster Signed-off-by: Stefan Hajnoczi --- block/vmdk.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index a8cb5c9..aef1abc 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -641,7 +641,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, * RW [size in sectors] SPARSE "file-name.vmdk" */ flat_offset = -1; - ret = sscanf(p, "%10s %" SCNd64 " %10s %511s %" SCNd64, + ret = sscanf(p, "%10s %" SCNd64 " %10s \"%511[^\n\r\"]\" %" SCNd64, access, §ors, type, fname, &flat_offset); if (ret < 4 || strcmp(access, "RW")) { goto next_line; @@ -653,14 +653,6 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, return -EINVAL; } - /* trim the quotation marks around */ - if (fname[0] == '"') { - memmove(fname, fname + 1, strlen(fname)); - if (strlen(fname) <= 1 || fname[strlen(fname) - 1] != '"') { - return -EINVAL; - } - fname[strlen(fname) - 1] = '\0'; - } if (sectors <= 0 || (strcmp(type, "FLAT") && strcmp(type, "SPARSE")) || (strcmp(access, "RW"))) { -- 1.8.1