From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48270) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvWCw-0007WV-UB for qemu-devel@nongnu.org; Wed, 16 Jan 2013 11:51:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TvWCv-0005w5-Sz for qemu-devel@nongnu.org; Wed, 16 Jan 2013 11:51:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:8714) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvWCv-0005vy-KW for qemu-devel@nongnu.org; Wed, 16 Jan 2013 11:51:21 -0500 From: Eduardo Habkost Date: Wed, 16 Jan 2013 13:24:09 -0200 Message-Id: <1358349851-20960-7-git-send-email-ehabkost@redhat.com> In-Reply-To: <1358349851-20960-1-git-send-email-ehabkost@redhat.com> References: <1358349851-20960-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [PATCH 6/8] vl.c: Use parse_uint_full() for NUMA nodeid List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Anthony Liguori Cc: Chegu Vinod 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 --- vl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vl.c b/vl.c index 3637a39..43ce607 100644 --- a/vl.c +++ b/vl.c @@ -1264,11 +1264,14 @@ 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) < 0) { + fprintf(stderr, "qemu: Invalid NUMA nodeid: %s\n", option); + exit(1); + } } if (nodenr >= MAX_NODES) { - fprintf(stderr, "qemu: invalid NUMA nodeid: %d\n", nodenr); + fprintf(stderr, "qemu: invalid NUMA nodeid: %llu\n", nodenr); exit(1); } -- 1.7.11.7