From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42819) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUap6-0004xF-97 for qemu-devel@nongnu.org; Fri, 11 Oct 2013 07:24:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VUap0-0000Gn-Bt for qemu-devel@nongnu.org; Fri, 11 Oct 2013 07:24:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19606) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUaoz-0000Ga-Vg for qemu-devel@nongnu.org; Fri, 11 Oct 2013 07:23:54 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9BBNqOR008805 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 11 Oct 2013 07:23:53 -0400 Date: Fri, 11 Oct 2013 13:23:51 +0200 From: Kevin Wolf Message-ID: <20131011112351.GG3112@dhcp-200-207.str.redhat.com> References: <1381471493-6464-1-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1381471493-6464-1-git-send-email-famz@redhat.com> Subject: Re: [Qemu-devel] [PATCH] vmdk: Fix vmdk_parse_extents List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: qemu-devel@nongnu.org, stefanha@redhat.com Am 11.10.2013 um 08:04 hat Fam Zheng geschrieben: > An extra 'p++' after while loop when *p == '\n' will move p to unknown > data position, risking parsing junk data or memory access violation. > > Cc: qemu-stable@nongnu.org > Signed-off-by: Fam Zheng > --- > block/vmdk.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/block/vmdk.c b/block/vmdk.c > index 5d56e31..f2dda21 100644 > --- a/block/vmdk.c > +++ b/block/vmdk.c > @@ -760,10 +760,13 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, > } > next_line: > /* move to next line */ > - while (*p && *p != '\n') { > + while (*p) { > p++; If the first not yet parsed character is \n, you're missing a line break now, aren't you? > + if (*p == '\n') { > + p++; > + break; > + } > } > - p++; > } > return 0; > } Kevin