From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47012) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGlK0-00069a-M4 for qemu-devel@nongnu.org; Fri, 21 Feb 2014 03:19:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WGlJn-0001ml-W6 for qemu-devel@nongnu.org; Fri, 21 Feb 2014 03:19:00 -0500 Received: from e38.co.us.ibm.com ([32.97.110.159]:43461) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGlJn-0001mZ-PU for qemu-devel@nongnu.org; Fri, 21 Feb 2014 03:18:47 -0500 Received: from /spool/local by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 21 Feb 2014 01:18:47 -0700 From: Michael Roth Date: Fri, 21 Feb 2014 02:17:11 -0600 Message-Id: <1392970647-21528-36-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1392970647-21528-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1392970647-21528-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 35/51] qemu_opts_parse(): always check return value List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: lersek@redhat.com, qemu-stable@nongnu.org, Petar.Jovanovic@imgtec.com From: Laszlo Ersek qemu_opts_parse() can always return NULL, even if the QemuOptsList.desc in question would be trivial to satisfy (eg. because it's empty). For example: qemu_opts_parse() opts_parse() qemu_opts_create() id_wellformed() In practice: $ .../qemu-system-x86_64 -acpitable id=3 qemu-system-x86_64: -acpitable id=3: Parameter 'id' expects an identifier ** ERROR:vl.c:3491:main: assertion failed: (opts != NULL) Aborted (core dumped) $ .../qemu-system-x86_64 -smbios id=3 qemu-system-x86_64: -smbios id=3: Parameter 'id' expects an identifier Segmentation fault (core dumped) I checked all qemu_opts_parse() invocations (and all drive_def() invocations too, because it blindly forwards the former's retval). Only the two above examples look problematic. Signed-off-by: Laszlo Ersek Reviewed-by: Markus Armbruster Message-id: 1385658779-7529-1-git-send-email-lersek@redhat.com Signed-off-by: Anthony Liguori (cherry picked from commit f46e720a82ccdf1a521cf459448f3f96ed895d43) Signed-off-by: Michael Roth --- vl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vl.c b/vl.c index 31e3411..30b5076 100644 --- a/vl.c +++ b/vl.c @@ -3489,11 +3489,16 @@ int main(int argc, char **argv, char **envp) } case QEMU_OPTION_acpitable: opts = qemu_opts_parse(qemu_find_opts("acpi"), optarg, 1); - g_assert(opts != NULL); + if (!opts) { + exit(1); + } do_acpitable_option(opts); break; case QEMU_OPTION_smbios: opts = qemu_opts_parse(qemu_find_opts("smbios"), optarg, 0); + if (!opts) { + exit(1); + } do_smbios_option(opts); break; case QEMU_OPTION_enable_kvm: -- 1.7.9.5