From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:53245) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QWihB-0007qv-Pc for qemu-devel@nongnu.org; Wed, 15 Jun 2011 01:31:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QWihA-0007WH-Dm for qemu-devel@nongnu.org; Wed, 15 Jun 2011 01:31:17 -0400 Received: from mail-yi0-f45.google.com ([209.85.218.45]:58173) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QWihA-0007WD-6a for qemu-devel@nongnu.org; Wed, 15 Jun 2011 01:31:16 -0400 Received: by yia25 with SMTP id 25so53318yia.4 for ; Tue, 14 Jun 2011 22:31:15 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <20110614080602.GA19123@stefanha-thinkpad.localdomain> Date: Wed, 15 Jun 2011 06:31:14 +0100 Message-ID: From: Stefan Hajnoczi Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 03/12] VMDK: probe for mono flat image List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: Kevin Wolf , qemu-devel@nongnu.org, Christoph Hellwig On Wed, Jun 15, 2011 at 5:26 AM, Fam Zheng wrote: > On Tue, Jun 14, 2011 at 4:06 PM, Stefan Hajnoczi wro= te: >> On Sat, Jun 04, 2011 at 08:40:50AM +0800, Fam Zheng wrote: >>> vmdk_probe for mono flat images. >>> >>> Signed-off-by: Fam Zheng >>> --- >>> =A0block/vmdk.c | =A0 13 ++++++++++--- >>> =A01 files changed, 10 insertions(+), 3 deletions(-) >>> >>> diff --git a/block/vmdk.c b/block/vmdk.c >>> index f787528..bf8d02a 100644 >>> --- a/block/vmdk.c >>> +++ b/block/vmdk.c >>> @@ -101,10 +101,17 @@ static int vmdk_probe(const uint8_t *buf, int >>> buf_size, const char *filename) >>> =A0 =A0 =A0 =A0 =A0return 0; >>> =A0 =A0 =A0magic =3D be32_to_cpu(*(uint32_t *)buf); >>> =A0 =A0 =A0if (magic =3D=3D VMDK3_MAGIC || >>> - =A0 =A0 =A0 =A0magic =3D=3D VMDK4_MAGIC) >>> + =A0 =A0 =A0 =A0magic =3D=3D VMDK4_MAGIC) { >>> =A0 =A0 =A0 =A0 =A0return 100; >>> - =A0 =A0else >>> - =A0 =A0 =A0 =A0return 0; >>> + =A0 =A0} else { >>> + =A0 =A0 =A0 =A0char *cid_p, *ct_p, *extent_p; >>> + =A0 =A0 =A0 =A0cid_p =3D strstr((char *)buf, "CID"); >>> + =A0 =A0 =A0 =A0ct_p =3D strstr((char *)buf, "createType"); >>> + =A0 =A0 =A0 =A0extent_p =3D strstr((char *)buf, "RW"); >>> + =A0 =A0 =A0 =A0if (cid_p && ct_p && extent_p) >>> + =A0 =A0 =A0 =A0 =A0 =A0return 100; >> >> NUL-terminated string functions cannot be used for probing because the >> input file may be invalid. =A0If the magic number matches but there is n= o >> NUL in the buffer then the strstr(3) will run off the end of the buffer. >> >> Also note that the specification says "The descriptor file is not >> case-sensitive". =A0"cid", "CiD", and "CID" should all be allowed. >> >> Do non-monolithic vmdk images always have "# Disk DescriptorFile" as the >> first line? =A0Perhaps you can test for that using memcmp(3) instead. > No guarantee in specification, although VMware does start descriptors > with such a line "# Disk DescriptorFile". > But is it proper that we make this assumption? Have you tried removing that comment line to see if VMware still recognizes the file? Stefan