[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 33/67] qapi: Fix crash when 'any' or 'null' paramet
From: |
Michael Roth |
Subject: |
[Qemu-stable] [PATCH 33/67] qapi: Fix crash when 'any' or 'null' parameter is missing |
Date: |
Wed, 14 Dec 2016 18:44:27 -0600 |
From: Marc-André Lureau <address@hidden>
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 <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Markus Armbruster <address@hidden>
[Commit message rephrased]
Signed-off-by: Markus Armbruster <address@hidden>
(cherry picked from commit c489780203f9b22aca5539ec7589b7140bdc951f)
Signed-off-by: Michael Roth <address@hidden>
---
qapi/qmp-input-visitor.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c
index 64dd392..fc91e74 100644
--- a/qapi/qmp-input-visitor.c
+++ b/qapi/qmp-input-visitor.c
@@ -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");
--
1.9.1
- [Qemu-stable] [PATCH 21/67] s390x/css: handle cssid 255 correctly, (continued)
- [Qemu-stable] [PATCH 21/67] s390x/css: handle cssid 255 correctly, Michael Roth, 2016/12/14
- [Qemu-stable] [PATCH 23/67] qcow2: fix encryption during cow of sectors, Michael Roth, 2016/12/14
- [Qemu-stable] [PATCH 22/67] vfio/pci: Fix regression in MSI routing configuration, Michael Roth, 2016/12/14
- [Qemu-stable] [PATCH 25/67] block: reintroduce bdrv_flush_all, Michael Roth, 2016/12/14
- [Qemu-stable] [PATCH 24/67] iscsi: Fix divide-by-zero regression on raw SG devices, Michael Roth, 2016/12/14
- [Qemu-stable] [PATCH 26/67] qemu: use bdrv_flush_all for vm_stop et al, Michael Roth, 2016/12/14
- [Qemu-stable] [PATCH 27/67] block-backend: remove blk_flush_all, Michael Roth, 2016/12/14
- [Qemu-stable] [PATCH 02/67] hw/ppc/spapr: Move code related to "ibm, pa-features" to a separate function, Michael Roth, 2016/12/14
- [Qemu-stable] [PATCH 30/67] qht: fix unlock-after-free segfault upon resizing, Michael Roth, 2016/12/14
- [Qemu-stable] [PATCH 29/67] qht: simplify qht_reset_size, Michael Roth, 2016/12/14
- [Qemu-stable] [PATCH 33/67] qapi: Fix crash when 'any' or 'null' parameter is missing,
Michael Roth <=
- [Qemu-stable] [PATCH 31/67] char: fix missing return in error path for chardev TLS init, Michael Roth, 2016/12/14
- [Qemu-stable] [PATCH 35/67] rbd: shift byte count as a 64-bit value, Michael Roth, 2016/12/14
- [Qemu-stable] [PATCH 34/67] tests/test-qmp-input-strict: Cover missing struct members, Michael Roth, 2016/12/14
- [Qemu-stable] [PATCH 37/67] throttle: Correct access to wrong BlockBackendPublic structures, Michael Roth, 2016/12/14
- [Qemu-stable] [PATCH 28/67] migrate: Fix cpu-throttle-increment regression in HMP, Michael Roth, 2016/12/14
- [Qemu-stable] [PATCH 32/67] qmp: fix object-add assert() without props, Michael Roth, 2016/12/14
- [Qemu-stable] [PATCH 36/67] ppc/kvm: Mark 64kB page size support as disabled if not available, Michael Roth, 2016/12/14
- [Qemu-stable] [PATCH 39/67] net: rtl8139: limit processing of ring descriptors, Michael Roth, 2016/12/14
- [Qemu-stable] [PATCH 41/67] memory: Don't use memcpy for ram_device regions, Michael Roth, 2016/12/14
- [Qemu-stable] [PATCH 38/67] qemu-iotests: Test I/O in a single drive from a throttling group, Michael Roth, 2016/12/14