qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Anthony Liguori <aliguori@us.ibm.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Philipp Hahn <hahn@univention.de>
Subject: [Qemu-devel] [PATCH 12/13] vmdk: Allow space in file name
Date: Fri,  1 Feb 2013 15:28:03 +0100	[thread overview]
Message-ID: <1359728884-19422-13-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1359728884-19422-1-git-send-email-stefanha@redhat.com>

From: Philipp Hahn <hahn@univention.de>

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 <hahn@univention.de>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 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, &sectors, 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

  parent reply	other threads:[~2013-02-01 14:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-01 14:27 [Qemu-devel] [PULL for-1.4 00/13] Block patches Stefan Hajnoczi
2013-02-01 14:27 ` [Qemu-devel] [PATCH 01/13] qemu-iotests: Add regression test for b7ab0fea Stefan Hajnoczi
2013-02-01 14:27 ` [Qemu-devel] [PATCH 02/13] block: Fix is_allocated_above with resized files Stefan Hajnoczi
2013-02-01 14:27 ` [Qemu-devel] [PATCH 03/13] block: Adds mirroring tests for resized images Stefan Hajnoczi
2013-02-01 14:27 ` [Qemu-devel] [PATCH 04/13] vmdk: Allow selecting SCSI adapter in image creation Stefan Hajnoczi
2013-02-01 14:27 ` [Qemu-devel] [PATCH 05/13] sheepdog: pass vdi_id to sheep daemon for sd_close() Stefan Hajnoczi
2013-02-01 14:27 ` [Qemu-devel] [PATCH 06/13] bochs: Fix bdrv_open() error handling Stefan Hajnoczi
2013-02-01 14:27 ` [Qemu-devel] [PATCH 07/13] cloop: " Stefan Hajnoczi
2013-02-01 14:27 ` [Qemu-devel] [PATCH 08/13] vpc: " Stefan Hajnoczi
2013-02-01 14:28 ` [Qemu-devel] [PATCH 09/13] dmg: " Stefan Hajnoczi
2013-02-02 12:47   ` Blue Swirl
2013-02-01 14:28 ` [Qemu-devel] [PATCH 10/13] dmg: Use g_free instead of free Stefan Hajnoczi
2013-02-01 14:28 ` [Qemu-devel] [PATCH 11/13] parallels: Fix bdrv_open() error handling Stefan Hajnoczi
2013-02-01 14:28 ` Stefan Hajnoczi [this message]
2013-02-01 14:28 ` [Qemu-devel] [PATCH 13/13] block/raw-posix: Build fix for O_ASYNC Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1359728884-19422-13-git-send-email-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=hahn@univention.de \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).