From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LWbOW-0004ZZ-JN for qemu-devel@nongnu.org; Mon, 09 Feb 2009 14:02:12 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LWbOV-0004ZL-NZ for qemu-devel@nongnu.org; Mon, 09 Feb 2009 14:02:12 -0500 Received: from [199.232.76.173] (port=52012 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LWbOV-0004ZI-Ig for qemu-devel@nongnu.org; Mon, 09 Feb 2009 14:02:11 -0500 Received: from savannah.gnu.org ([199.232.41.3]:34354 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LWbOV-0003Qm-6Z for qemu-devel@nongnu.org; Mon, 09 Feb 2009 14:02:11 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1LWbOU-0006zc-Bg for qemu-devel@nongnu.org; Mon, 09 Feb 2009 19:02:10 +0000 Received: from aurel32 by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1LWbOT-0006zY-Qs for qemu-devel@nongnu.org; Mon, 09 Feb 2009 19:02:10 +0000 MIME-Version: 1.0 Errors-To: aurel32 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Aurelien Jarno Message-Id: Date: Mon, 09 Feb 2009 19:02:09 +0000 Subject: [Qemu-devel] [6580] Fix crash caused by missing command line arguments Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 6580 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6580 Author: aurel32 Date: 2009-02-09 19:02:09 +0000 (Mon, 09 Feb 2009) Log Message: ----------- Fix crash caused by missing command line arguments Signed-off-by: Stefan Weil Signed-off-by: Aurelien Jarno Modified Paths: -------------- trunk/linux-user/main.c Modified: trunk/linux-user/main.c =================================================================== --- trunk/linux-user/main.c 2009-02-09 18:28:36 UTC (rev 6579) +++ trunk/linux-user/main.c 2009-02-09 19:02:09 UTC (rev 6580) @@ -2301,6 +2301,8 @@ if (envlist_unsetenv(envlist, r) != 0) usage(); } else if (!strcmp(r, "s")) { + if (optind >= argc) + break; r = argv[optind++]; x86_stack_size = strtol(r, (char **)&r, 0); if (x86_stack_size <= 0) @@ -2312,6 +2314,8 @@ } else if (!strcmp(r, "L")) { interp_prefix = argv[optind++]; } else if (!strcmp(r, "p")) { + if (optind >= argc) + break; qemu_host_page_size = atoi(argv[optind++]); if (qemu_host_page_size == 0 || (qemu_host_page_size & (qemu_host_page_size - 1)) != 0) { @@ -2319,12 +2323,14 @@ exit(1); } } else if (!strcmp(r, "g")) { + if (optind >= argc) + break; gdbstub_port = atoi(argv[optind++]); } else if (!strcmp(r, "r")) { qemu_uname_release = argv[optind++]; } else if (!strcmp(r, "cpu")) { cpu_model = argv[optind++]; - if (strcmp(cpu_model, "?") == 0) { + if (cpu_model == NULL || strcmp(cpu_model, "?") == 0) { /* XXX: implement xxx_cpu_list for targets that still miss it */ #if defined(cpu_list) cpu_list(stdout, &fprintf);