[libvirt] [PATCH 7/7] qemu: Check for missing 'return' in qemuMonitorJSONCheckReply
Peter Krempa
pkrempa at redhat.com
Wed Apr 18 07:05:51 UTC 2018
On Tue, Apr 17, 2018 at 12:22:18 -0400, John Ferlan wrote:
> If the "return" is not in the reply, then the subsequent
> virJSONValueGetType will not be happy.
>
> Found by Coverity
>
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
> src/qemu/qemu_monitor_json.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index 410fa178b2..681c0575c3 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -423,7 +423,12 @@ qemuMonitorJSONCheckReply(virJSONValuePtr cmd,
> if (qemuMonitorJSONCheckError(cmd, reply) < 0)
This checks that the reply indeed has a key named 'return'.
> return -1;
>
> - data = virJSONValueObjectGet(reply, "return");
So this is not possible to fail.
> + if (!(data = virJSONValueObjectGet(reply, "return"))) {
> + virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> + _("missing 'return' for returned data"));
> + return -1;
> + }
> +
> if (virJSONValueGetType(data) != type) {
> char *cmdstr = virJSONValueToString(cmd, false);
> char *retstr = virJSONValueToString(data, false);
> --
> 2.13.6
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180418/21da40fa/attachment-0001.sig>
More information about the libvir-list
mailing list