From patchwork Wed Feb 17 11:32:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 45605 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 78966B7C7E for ; Wed, 17 Feb 2010 22:34:39 +1100 (EST) Received: from localhost ([127.0.0.1]:43918 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NhiAj-0001FE-1H for incoming@patchwork.ozlabs.org; Wed, 17 Feb 2010 06:34:25 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NhiAD-0001F9-BC for qemu-devel@nongnu.org; Wed, 17 Feb 2010 06:33:53 -0500 Received: from [199.232.76.173] (port=36336 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NhiAB-0001F1-RH for qemu-devel@nongnu.org; Wed, 17 Feb 2010 06:33:51 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NhiAA-0002FZ-Ej for qemu-devel@nongnu.org; Wed, 17 Feb 2010 06:33:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:25401) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NhiAA-0002F8-20 for qemu-devel@nongnu.org; Wed, 17 Feb 2010 06:33:50 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1HBXl17015825 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 17 Feb 2010 06:33:48 -0500 Received: from localhost.localdomain (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1HBXkUB001824; Wed, 17 Feb 2010 06:33:46 -0500 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Wed, 17 Feb 2010 12:32:59 +0100 Message-Id: <1266406379-5029-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com Subject: [Qemu-devel] [PATCH] qemu-img: Fix segfault during rebase X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This fixes a possible read beyond the end of the temporary buffers used for comparing data in the old and the new backing file. Signed-off-by: Kevin Wolf --- qemu-img.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 250d892..258dc62 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1225,7 +1225,7 @@ static int img_rebase(int argc, char **argv) int pnum; if (compare_sectors(buf_old + written * 512, - buf_new + written * 512, n, &pnum)) + buf_new + written * 512, n - written, &pnum)) { ret = bdrv_write(bs, sector + written, buf_old + written * 512, pnum);