From patchwork Fri Oct 11 15:05:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 282820 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A1CC82C00BA for ; Sat, 12 Oct 2013 02:33:50 +1100 (EST) Received: from localhost ([::1]:55052 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUeiq-0003J9-O2 for incoming@patchwork.ozlabs.org; Fri, 11 Oct 2013 11:33:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43709) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUeJi-000105-Lq for qemu-devel@nongnu.org; Fri, 11 Oct 2013 11:07:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VUeJd-00060S-Lg for qemu-devel@nongnu.org; Fri, 11 Oct 2013 11:07:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15710) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUeJd-00060L-Ds for qemu-devel@nongnu.org; Fri, 11 Oct 2013 11:07:45 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9BF7icq012535 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 11 Oct 2013 11:07:44 -0400 Received: from dhcp-200-207.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r9BF5s3G006329; Fri, 11 Oct 2013 11:07:42 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Fri, 11 Oct 2013 17:05:49 +0200 Message-Id: <1381503951-27985-60-git-send-email-kwolf@redhat.com> In-Reply-To: <1381503951-27985-1-git-send-email-kwolf@redhat.com> References: <1381503951-27985-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 59/61] vmdk: Fix vmdk_parse_extents 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 From: Fam Zheng 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 Signed-off-by: Kevin Wolf --- block/vmdk.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index 709aa3d..5a9f278 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -772,10 +772,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; }