From patchwork Tue Jan 29 21:50:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Hahn X-Patchwork-Id: 216776 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AEF922C0093 for ; Wed, 30 Jan 2013 18:17:02 +1100 (EST) Received: from localhost ([::1]:52446 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U0Rul-0005ou-VP for incoming@patchwork.ozlabs.org; Wed, 30 Jan 2013 02:16:59 -0500 Received: from eggs.gnu.org ([208.118.235.92]:60778) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U0Rub-0005mN-9O for qemu-devel@nongnu.org; Wed, 30 Jan 2013 02:16:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U0RuX-0006kB-TE for qemu-devel@nongnu.org; Wed, 30 Jan 2013 02:16:49 -0500 Received: from mail.univention.de ([82.198.197.8]:1277) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U0RuX-0006iz-NN for qemu-devel@nongnu.org; Wed, 30 Jan 2013 02:16:45 -0500 Received: from localhost (localhost [127.0.0.1]) by slugis.knut.univention.de (Postfix) with ESMTP id 93AA014138B8 for ; Wed, 30 Jan 2013 08:16:43 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by slugis.knut.univention.de (Postfix) with ESMTP id 86BB914138BB for ; Wed, 30 Jan 2013 08:16:43 +0100 (CET) X-Virus-Scanned: by amavisd-new-2.6.1 (20080629) (Debian) at knut.univention.de Received: from mail.univention.de ([127.0.0.1]) by localhost (slugis.knut.univention.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jMkUXEoCFb8Y for ; Wed, 30 Jan 2013 08:16:43 +0100 (CET) Received: from stave.knut.univention.de (mail.univention.de [82.198.197.8]) by slugis.knut.univention.de (Postfix) with ESMTPSA id 22CFB14138B8 for ; Wed, 30 Jan 2013 08:16:41 +0100 (CET) Resent-From: Philipp Hahn Resent-To: qemu-devel@nongnu.org Resent-Date: Wed, 30 Jan 2013 07:13:39 +0100 Resent-Message-ID: <201301300713.39789.hahn@univention.de> Message-Id: <25564d1eb38c6305f7cb1d1a37cec154acc1a51e.1359526037.git.hahn@univention.de> From: Philipp Hahn Date: Tue, 29 Jan 2013 22:50:31 +0100 Organization: Univention GmbH, Bremen, Germany To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 82.198.197.8 Subject: [Qemu-devel] [PATCH] vmdk: Allow space in file name X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Wokrstation. 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 --- block/vmdk.c | 10 +--------- 1 files changed, 1 insertions(+), 9 deletions(-) [V2] Also remove " striping code. Add \n\r to stop character set. diff --git a/block/vmdk.c b/block/vmdk.c index 19298c2..20ad646 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"))) {