From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49900) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cilkE-0003d0-KN for qemu-devel@nongnu.org; Tue, 28 Feb 2017 12:39:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cilkB-0005PI-E8 for qemu-devel@nongnu.org; Tue, 28 Feb 2017 12:39:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48336) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cilkB-0005P1-7d for qemu-devel@nongnu.org; Tue, 28 Feb 2017 12:39:23 -0500 From: Markus Armbruster Date: Tue, 28 Feb 2017 18:38:55 +0100 Message-Id: <1488303560-18803-2-git-send-email-armbru@redhat.com> In-Reply-To: <1488303560-18803-1-git-send-email-armbru@redhat.com> References: <1488303560-18803-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH v3 01/26] qga: Fix crash on non-dictionary QMP argument List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: eblake@redhat.com, Michael Roth The value of key 'arguments' must be a JSON object. qemu-ga neglects to check, and crashes. To reproduce, send { 'execute': 'guest-sync', 'arguments': [] } to qemu-ga. do_qmp_dispatch() uses qdict_get_qdict() to get the arguments. When not a JSON object, this gets a null pointer, which flows through the generated marshalling function to qobject_input_visitor_new(), where it fails the assertion. qmp_dispatch_check_obj() needs to catch this error. QEMU isn't affected, because it runs qmp_check_input_obj() first, which basically duplicates qmp_dispatch_check_obj()'s checks, plus the missing one. Fix by copying the missing one from qmp_check_input_obj() to qmp_dispatch_check_obj(). Signed-off-by: Markus Armbruster Cc: Michael Roth Reviewed-by: Eric Blake --- qapi/qmp-dispatch.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index 48bec20..621922f 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -47,7 +47,13 @@ static QDict *qmp_dispatch_check_obj(const QObject *request, Error **errp) return NULL; } has_exec_key = true; - } else if (strcmp(arg_name, "arguments")) { + } else if (!strcmp(arg_name, "arguments")) { + if (qobject_type(arg_obj) != QTYPE_QDICT) { + error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER, + "arguments", "object"); + return NULL; + } + } else { error_setg(errp, QERR_QMP_EXTRA_MEMBER, arg_name); return NULL; } -- 2.7.4