]> Git Repo - qemu.git/commitdiff
qapi: Fix crash when 'any' or 'null' parameter is missing
authorMarc-André Lureau <[email protected]>
Thu, 22 Sep 2016 20:39:26 +0000 (00:39 +0400)
committerMarkus Armbruster <[email protected]>
Thu, 6 Oct 2016 12:47:41 +0000 (14:47 +0200)
Unlike the other visit methods, visit_type_any() and visit_type_null()
neglect to check whether qmp_input_get_object() succeeded.  They crash
when it fails.  Reproducer:

{ "execute": "qom-set",
  "arguments": { "path": "/machine", "property": "rtc-time" } }

Will crash with:

qapi/qapi-visit-core.c:277: visit_type_any: Assertion `!err != !*obj'
failed

Broken in commit 5c678ee.  Fix by adding the missing error checks.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Message-Id: <20160922203927[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
[Commit message rephrased]
Signed-off-by: Markus Armbruster <[email protected]>
qapi/qmp-input-visitor.c

index 64dd392e6f7a1999fb39de488c12ded5539d9e9b..fc91e7489406127e9de05c84b55bd7c658ded920 100644 (file)
@@ -338,6 +338,12 @@ static void qmp_input_type_any(Visitor *v, const char *name, QObject **obj,
     QmpInputVisitor *qiv = to_qiv(v);
     QObject *qobj = qmp_input_get_object(qiv, name, true);
 
+    if (!qobj) {
+        error_setg(errp, QERR_MISSING_PARAMETER, name ? name : "null");
+        *obj = NULL;
+        return;
+    }
+
     qobject_incref(qobj);
     *obj = qobj;
 }
@@ -347,6 +353,11 @@ static void qmp_input_type_null(Visitor *v, const char *name, Error **errp)
     QmpInputVisitor *qiv = to_qiv(v);
     QObject *qobj = qmp_input_get_object(qiv, name, true);
 
+    if (!qobj) {
+        error_setg(errp, QERR_MISSING_PARAMETER, name ? name : "null");
+        return;
+    }
+
     if (qobject_type(qobj) != QTYPE_QNULL) {
         error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
                    "null");
This page took 0.027413 seconds and 4 git commands to generate.