[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/8] qapi: protect against NULL QObject in qmp_input
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 2/8] qapi: protect against NULL QObject in qmp_input_get_object |
Date: |
Fri, 16 Dec 2011 13:01:52 +0100 |
A NULL qobj can occur when a parameter is fetched via qdict_get, but
the parameter is not in the command. By returning NULL, the caller can
choose whether to raise a missing parameter error, an invalid parameter
type error, or use a default value. For example, qom-set could can
use this to reset a property to its default value, though at this time
it will fail with "Invalid parameter type". In any case, anything is
better than crashing!
Signed-off-by: Paolo Bonzini <address@hidden>
---
qapi/qmp-input-visitor.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c
index 8cbc0ab..c78022b 100644
--- a/qapi/qmp-input-visitor.c
+++ b/qapi/qmp-input-visitor.c
@@ -49,10 +49,12 @@ static const QObject *qmp_input_get_object(QmpInputVisitor
*qiv,
qobj = qiv->stack[qiv->nb_stack - 1].obj;
}
- if (name && qobject_type(qobj) == QTYPE_QDICT) {
- return qdict_get(qobject_to_qdict(qobj), name);
- } else if (qiv->nb_stack > 0 && qobject_type(qobj) == QTYPE_QLIST) {
- return qlist_entry_obj(qiv->stack[qiv->nb_stack - 1].entry);
+ if (qobj) {
+ if (name && qobject_type(qobj) == QTYPE_QDICT) {
+ return qdict_get(qobject_to_qdict(qobj), name);
+ } else if (qiv->nb_stack > 0 && qobject_type(qobj) == QTYPE_QLIST) {
+ return qlist_entry_obj(qiv->stack[qiv->nb_stack - 1].entry);
+ }
}
return qobj;
--
1.7.7.1
- Re: [Qemu-devel] [PATCH 1/8] qapi: fix NULL pointer dereference, (continued)
- Re: [Qemu-devel] [PATCH 1/8] qapi: fix NULL pointer dereference, Paolo Bonzini, 2011/12/16
- Re: [Qemu-devel] [PATCH 1/8] qapi: fix NULL pointer dereference, Anthony Liguori, 2011/12/16
- Re: [Qemu-devel] [PATCH 1/8] qapi: fix NULL pointer dereference, Paolo Bonzini, 2011/12/16
- Re: [Qemu-devel] [PATCH 1/8] qapi: fix NULL pointer dereference, Anthony Liguori, 2011/12/16
- Re: [Qemu-devel] [PATCH 1/8] qapi: fix NULL pointer dereference, Paolo Bonzini, 2011/12/16
- Re: [Qemu-devel] [PATCH 1/8] qapi: fix NULL pointer dereference, Anthony Liguori, 2011/12/16
- Re: [Qemu-devel] [PATCH 1/8] qapi: fix NULL pointer dereference, Paolo Bonzini, 2011/12/16
- Re: [Qemu-devel] [PATCH 1/8] qapi: fix NULL pointer dereference, Anthony Liguori, 2011/12/16
- Re: [Qemu-devel] [PATCH 1/8] qapi: fix NULL pointer dereference, Paolo Bonzini, 2011/12/16
- Re: [Qemu-devel] [PATCH 1/8] qapi: fix NULL pointer dereference, Gerd Hoffmann, 2011/12/16
[Qemu-devel] [PATCH 2/8] qapi: protect against NULL QObject in qmp_input_get_object,
Paolo Bonzini <=
[Qemu-devel] [PATCH 4/8] qom: push permission checks up into qdev_property_add_legacy, Paolo Bonzini, 2011/12/16
[Qemu-devel] [PATCH 6/8] qom: introduce get/set methods for Property, Paolo Bonzini, 2011/12/16
[Qemu-devel] [PATCH 8/8] qom: register qdev properties also as non-legacy properties, Paolo Bonzini, 2011/12/16