From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:48639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RSlzb-0006OJ-Fp for qemu-devel@nongnu.org; Tue, 22 Nov 2011 03:46:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RSlza-00008w-1f for qemu-devel@nongnu.org; Tue, 22 Nov 2011 03:46:15 -0500 Received: from oxygen.pond.sub.org ([78.46.104.156]:53675) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RSlzZ-00007O-N7 for qemu-devel@nongnu.org; Tue, 22 Nov 2011 03:46:13 -0500 Received: from blackfin.pond.sub.org (p5B32D94C.dip.t-dialin.net [91.50.217.76]) by oxygen.pond.sub.org (Postfix) with ESMTPA id A22FDA4111 for ; Tue, 22 Nov 2011 09:46:07 +0100 (CET) From: Markus Armbruster Date: Tue, 22 Nov 2011 09:46:03 +0100 Message-Id: <1321951566-11667-4-git-send-email-armbru@redhat.com> In-Reply-To: <1321951566-11667-1-git-send-email-armbru@redhat.com> References: <1321951566-11667-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH 3/6] vl: Tighten parsing of -m argument List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Jes.Sorensen@redhat.com strtosz_suffix() fails unless the size is followed by 0, whitespace or ','. Useless here, because we need to fail for any junk following the size, even if it starts with whitespace or ','. Check manually. Things like "-m 1024," are now caught. Signed-off-by: Markus Armbruster --- vl.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/vl.c b/vl.c index b9146cf..a50842b 100644 --- a/vl.c +++ b/vl.c @@ -2535,9 +2535,10 @@ int main(int argc, char **argv, char **envp) break; case QEMU_OPTION_m: { int64_t value; + char *end; - value = strtosz(optarg, NULL); - if (value < 0) { + value = strtosz(optarg, &end); + if (value < 0 || *end) { fprintf(stderr, "qemu: invalid ram size: %s\n", optarg); exit(1); } -- 1.7.6.4