From patchwork Wed Jan 16 18:28:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 212942 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id ABF0B2C0082 for ; Thu, 17 Jan 2013 05:27:48 +1100 (EST) Received: from localhost ([::1]:42247 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvXiE-000744-Ns for incoming@patchwork.ozlabs.org; Wed, 16 Jan 2013 13:27:46 -0500 Received: from eggs.gnu.org ([208.118.235.92]:41517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvXhu-0006ve-RB for qemu-devel@nongnu.org; Wed, 16 Jan 2013 13:27:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TvXht-0008Iy-5d for qemu-devel@nongnu.org; Wed, 16 Jan 2013 13:27:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:1202) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvXhs-0008Ic-Sy for qemu-devel@nongnu.org; Wed, 16 Jan 2013 13:27:25 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0GIRN6j011853 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 16 Jan 2013 13:27:23 -0500 Received: from blackpad.lan.raisama.net (vpn1-7-107.gru2.redhat.com [10.97.7.107]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0GIRMBw013718; Wed, 16 Jan 2013 13:27:22 -0500 Received: by blackpad.lan.raisama.net (Postfix, from userid 500) id E422A202B53; Wed, 16 Jan 2013 16:28:59 -0200 (BRST) From: Eduardo Habkost To: qemu-devel@nongnu.org, Anthony Liguori Date: Wed, 16 Jan 2013 16:28:51 -0200 Message-Id: <1358360933-5323-7-git-send-email-ehabkost@redhat.com> In-Reply-To: <1358360933-5323-1-git-send-email-ehabkost@redhat.com> References: <1358360933-5323-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Chegu Vinod Subject: [Qemu-devel] [PATCH 6/8] vl.c: Use parse_uint_full() for NUMA nodeid 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 This should catch many kinds of errors that the current code wasn't checking for: - Values that can't be parsed as a number - Negative values - Overflow - Empty string Signed-off-by: Eduardo Habkost --- Cc: Eric Blake Changes v2: - Use base=10 to keep the existing behavior --- vl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vl.c b/vl.c index b39cd9a..abc2af5 100644 --- a/vl.c +++ b/vl.c @@ -1264,7 +1264,10 @@ static void numa_add(const char *optarg) if (get_param_value(option, 128, "nodeid", optarg) == 0) { nodenr = nb_numa_nodes; } else { - nodenr = strtoull(option, NULL, 10); + if (parse_uint_full(option, &nodenr, 10) < 0) { + fprintf(stderr, "qemu: Invalid NUMA nodeid: %s\n", option); + exit(1); + } } if (nodenr >= MAX_NODES) {