Patchwork Monitor: Fix command execution regression

login
register
mail settings
Submitter Luiz Capitulino
Date Jan. 27, 2010, 8:01 p.m.
Message ID <20100127180117.5cf438bf@doriath>
Download mbox | patch
Permalink /patch/43832/
State New
Headers show

Comments

Luiz Capitulino - Jan. 27, 2010, 8:01 p.m.
Function is_async_return() added by commit 940cc30d0d4 assumes
that 'data', which is returned by handlers, is always a QDict.

This is not true, as QLists can also be returned, in this case
we'll get a segfault.

Fix that by checking if 'data' is a QDict.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
Blue Swirl - Jan. 28, 2010, 7:20 p.m.
Thanks, applied.


On Wed, Jan 27, 2010 at 8:01 PM, Luiz Capitulino <lcapitulino@redhat.com> wrote:
>
> Function is_async_return() added by commit 940cc30d0d4 assumes
> that 'data', which is returned by handlers, is always a QDict.
>
> This is not true, as QLists can also be returned, in this case
> we'll get a segfault.
>
> Fix that by checking if 'data' is a QDict.
>
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> ---
>  monitor.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/monitor.c b/monitor.c
> index fbae5ce..fb7c572 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -3700,7 +3700,11 @@ static void monitor_print_error(Monitor *mon)
>
>  static int is_async_return(const QObject *data)
>  {
> -    return data && qdict_haskey(qobject_to_qdict(data), "__mon_async");
> +    if (data && qobject_type(data) == QTYPE_QDICT) {
> +        return qdict_haskey(qobject_to_qdict(data), "__mon_async");
> +    }
> +
> +    return 0;
>  }
>
>  static void monitor_call_handler(Monitor *mon, const mon_cmd_t *cmd,
> --
> 1.6.6
>
>
>
>

Patch

diff --git a/monitor.c b/monitor.c
index fbae5ce..fb7c572 100644
--- a/monitor.c
+++ b/monitor.c
@@ -3700,7 +3700,11 @@  static void monitor_print_error(Monitor *mon)
 
 static int is_async_return(const QObject *data)
 {
-    return data && qdict_haskey(qobject_to_qdict(data), "__mon_async");
+    if (data && qobject_type(data) == QTYPE_QDICT) {
+        return qdict_haskey(qobject_to_qdict(data), "__mon_async");
+    }
+
+    return 0;
 }
 
 static void monitor_call_handler(Monitor *mon, const mon_cmd_t *cmd,