From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45129) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vi3Bj-0004zc-W7 for qemu-devel@nongnu.org; Sun, 17 Nov 2013 09:19:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vi3Bd-0005Z4-EZ for qemu-devel@nongnu.org; Sun, 17 Nov 2013 09:18:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60612) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vi3Bd-0005Yw-7G for qemu-devel@nongnu.org; Sun, 17 Nov 2013 09:18:53 -0500 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 rAHEIqui009834 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 17 Nov 2013 09:18:52 -0500 From: Max Reitz Date: Sun, 17 Nov 2013 15:18:44 +0100 Message-Id: <1384697924-16918-5-git-send-email-mreitz@redhat.com> In-Reply-To: <1384697924-16918-1-git-send-email-mreitz@redhat.com> References: <1384697924-16918-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH 4/4] qcow2: Check validity of backing file name length List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi , Max Reitz The len variable is a signed integer, therefore it may overflow when reading the backing file name length from the qcow2 image header. This case should be handled explicitly. Signed-off-by: Max Reitz --- block/qcow2.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index 9c29e1a..e54176e 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -630,6 +630,11 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, /* read the backing file name */ if (header.backing_file_offset != 0) { len = header.backing_file_size; + if (len < 0) { + error_setg(errp, "Backing file name length is negative"); + ret = -EINVAL; + goto fail; + } if (len > 1023) { len = 1023; } -- 1.8.4.2