From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVXPK-0004i7-FY for qemu-devel@nongnu.org; Sun, 13 Oct 2013 21:57:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VVXPF-0007Px-FZ for qemu-devel@nongnu.org; Sun, 13 Oct 2013 21:57:18 -0400 Date: Mon, 14 Oct 2013 09:57:08 +0800 From: Fam Zheng Message-ID: <20131014015708.GA9183@T430s.nay.redhat.com> References: <1381492109-24999-1-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1381492109-24999-1-git-send-email-famz@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2] vmdk: Fix vmdk_parse_extents Reply-To: famz@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org Cc'ing qemu-stable@nongnu.org. On Fri, 10/11 19:48, Fam Zheng wrote: > 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..21f0fa7 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) { > + if (*p == '\n') { > + p++; > + break; > + } > p++; > } > - p++; > } > return 0; > } > -- > 1.8.3.1 > >