Re: [PATCH 7/7] qemu: Check for missing 'return' in qemuMonitorJSONCheckReply

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> ---
>  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@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/libvir-list

Attachment: signature.asc
Description: PGP signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux