diff options
author | Michael Roth <mdroth@linux.vnet.ibm.com> | 2014-09-18 15:36:40 -0500 |
---|---|---|
committer | Luiz Capitulino <lcapitulino@redhat.com> | 2014-09-26 13:14:10 -0400 |
commit | cee2dedb85b97e4976c83bea84064c3921b8b7ac (patch) | |
tree | 4c98449fe16c7d477ae2d43ba8ec85018e0c0597 /include/qapi/visitor.h | |
parent | 1f9296b51a26650916a2c4191268bb64057bdc5f (diff) | |
download | hqemu-cee2dedb85b97e4976c83bea84064c3921b8b7ac.zip hqemu-cee2dedb85b97e4976c83bea84064c3921b8b7ac.tar.gz |
qapi: add visit_start_union and visit_end_union
In some cases an input visitor might bail out on filling out a
struct for various reasons, such as missing fields when running
in strict mode. In the case of a QAPI Union type, this may lead
to cases where the .kind field which encodes the union type
is uninitialized. Subsequently, other visitors, such as the
dealloc visitor, may use this .kind value as if it were
initialized, leading to assumptions about the union type which
in this case may lead to segfaults. For example, freeing an
integer value.
However, we can generally rely on the fact that the always-present
.data void * field that we generate for these union types will
always be NULL in cases where .kind is uninitialized (at least,
there shouldn't be a reason where we'd do this purposefully).
So pass this information on to Visitor implementation via these
optional start_union/end_union interfaces so this information
can be used to guard against the situation above. We will make
use of this information in a subsequent patch for the dealloc
visitor.
Cc: qemu-stable@nongnu.org
Reported-by: Fam Zheng <famz@redhat.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'include/qapi/visitor.h')
-rw-r--r-- | include/qapi/visitor.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index 4a0178f..5934f59 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -58,5 +58,7 @@ void visit_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp); void visit_type_bool(Visitor *v, bool *obj, const char *name, Error **errp); void visit_type_str(Visitor *v, char **obj, const char *name, Error **errp); void visit_type_number(Visitor *v, double *obj, const char *name, Error **errp); +bool visit_start_union(Visitor *v, bool data_present, Error **errp); +void visit_end_union(Visitor *v, bool data_present, Error **errp); #endif |