From patchwork Thu Jan 24 16:29:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Hahn X-Patchwork-Id: 215434 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 508842C00B8 for ; Fri, 25 Jan 2013 03:30:02 +1100 (EST) Received: from localhost ([::1]:41645 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyPge-00038O-Fk for incoming@patchwork.ozlabs.org; Thu, 24 Jan 2013 11:30:00 -0500 Received: from eggs.gnu.org ([208.118.235.92]:60883) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyPgP-000365-Cm for qemu-devel@nongnu.org; Thu, 24 Jan 2013 11:29:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TyPgK-0004sf-Qc for qemu-devel@nongnu.org; Thu, 24 Jan 2013 11:29:45 -0500 Received: from mail.univention.de ([82.198.197.8]:2811) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyPgK-0004sE-KG for qemu-devel@nongnu.org; Thu, 24 Jan 2013 11:29:40 -0500 Received: from localhost (localhost [127.0.0.1]) by slugis.knut.univention.de (Postfix) with ESMTP id 2906714138B2; Thu, 24 Jan 2013 17:29:37 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by slugis.knut.univention.de (Postfix) with ESMTP id 1DD6C14138B3; Thu, 24 Jan 2013 17:29:37 +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 JaBq4DabIDFn; Thu, 24 Jan 2013 17:29:36 +0100 (CET) Received: from stave.knut.univention.de (mail.univention.de [82.198.197.8]) by slugis.knut.univention.de (Postfix) with ESMTPSA id 6004814138B2; Thu, 24 Jan 2013 17:29:36 +0100 (CET) From: Philipp Hahn Organization: Univention.de To: qemu-devel@nongnu.org Date: Thu, 24 Jan 2013 17:29:27 +0100 User-Agent: KMail/1.9.10 (enterprise35 20100903.1171286) MIME-Version: 1.0 Message-Id: <201301241729.31903.hahn@univention.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 82.198.197.8 Cc: Kevin Wolf , Stefan Hajnoczi Subject: [Qemu-devel] [BUG, RFC] block/vmdk.c: File name with space fails to open 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 Hello, I tried to open a "twoGbMaxExtentSparse" VMDK file, which uses spaces in its own and for the referenced file names. This breaks in line 646 of block/vmdk.c because "%511s" stops at the first space and thus fname is incomplete: ret = sscanf(p, "%10s %" SCNd64 " %10s %511s %" SCNd64, access, §ors, type, fname, &flat_offset); I've only checked with our very old VMware workstation version, which refuses to create new images with unsupported characters with the following message: > The characters !#%^&*><:;'"<>/? cannot be used. So it looks like spaces are valid, at least we have several VMs with spaces in their name. If the quotes around the file name are required, the simpliest solution would be to change %511s to "%511[^"]": goto next_line; I don't know how portable %[ together with a maximum width is, because the manual page for sscanf() doesn't mention "max width" for "%[", but it works with Debian/GNU Linux Squeeze. Sincerely Philipp diff --git a/block/vmdk.c b/block/vmdk.c index 19298c2..045f6a1 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[^\"]\" %" SCNd64, access, §ors, type, fname, &flat_offset); if (ret < 4 || strcmp(access, "RW")) {