From patchwork Tue Jul 6 15:33:25 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 58041 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 83DC3B6EDD for ; Wed, 7 Jul 2010 01:54:48 +1000 (EST) Received: from localhost ([127.0.0.1]:51677 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OWASo-0000zj-Sm for incoming@patchwork.ozlabs.org; Tue, 06 Jul 2010 11:53:39 -0400 Received: from [140.186.70.92] (port=39478 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OWA9j-0006S8-Qg for qemu-devel@nongnu.org; Tue, 06 Jul 2010 11:33:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OWA9i-0000Bj-Ls for qemu-devel@nongnu.org; Tue, 06 Jul 2010 11:33:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38844) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OWA9i-0000BT-FG for qemu-devel@nongnu.org; Tue, 06 Jul 2010 11:33:54 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o66FXqPv004771 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 6 Jul 2010 11:33:52 -0400 Received: from localhost.localdomain (dhcp-5-217.str.redhat.com [10.32.5.217]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o66FXTsx012071; Tue, 6 Jul 2010 11:33:51 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Tue, 6 Jul 2010 17:33:25 +0200 Message-Id: <1278430406-18667-17-git-send-email-kwolf@redhat.com> In-Reply-To: <1278430406-18667-1-git-send-email-kwolf@redhat.com> References: <1278430406-18667-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 16/17] ide: Reject invalid CHS geometry 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 From: Markus Armbruster drive_init() doesn't permit invalid CHS for if=ide, but that's worthless: we get it via if=none and -device. Signed-off-by: Markus Armbruster Signed-off-by: Kevin Wolf --- hw/ide/core.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index 3b84bea..af52c2c 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -2604,6 +2604,18 @@ int ide_init_drive(IDEState *s, BlockDriverState *bs, s->bs = bs; bdrv_get_geometry(bs, &nb_sectors); bdrv_guess_geometry(bs, &cylinders, &heads, &secs); + if (cylinders < 1 || cylinders > 16383) { + error_report("cyls must be between 1 and 16383"); + return -1; + } + if (heads < 1 || heads > 16) { + error_report("heads must be between 1 and 16"); + return -1; + } + if (secs < 1 || secs > 63) { + error_report("secs must be between 1 and 63"); + return -1; + } s->cylinders = cylinders; s->heads = heads; s->sectors = secs;