qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] fuzz: Expect the cmdline in a freeable GString


From: Thomas Huth
Subject: Re: [PATCH] fuzz: Expect the cmdline in a freeable GString
Date: Wed, 15 Jul 2020 15:58:18 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

On 14/07/2020 19.46, Alexander Bulekov wrote:
> In the initial FuzzTarget, get_init_cmdline returned a char *. With this
> API, we had no guarantee about where the string came from. For example,
> i440fx-qtest-reboot-fuzz simply returned a pointer to a string literal,
> while the QOS-based targets build the arguments out in a GString an
> return the gchar *str pointer. Since we did not try to free the cmdline,
> we have a leak for any targets that do not simply return string
> literals. Clean up this mess by forcing fuzz-targets to return
> a GString, that we can free.
> 
> Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
> ---
>  tests/qtest/fuzz/fuzz.c        | 13 ++++++-------
>  tests/qtest/fuzz/fuzz.h        |  6 +++---
>  tests/qtest/fuzz/i440fx_fuzz.c |  4 ++--
>  tests/qtest/fuzz/qos_fuzz.c    |  6 +++---
>  4 files changed, 14 insertions(+), 15 deletions(-)
      /* Prepend the arguments that we need */
>      g_string_prepend(cmd_line,
>              TARGET_NAME " -display none -machine accel=qtest -m 64 ");
> -    return cmd_line->str;
> +    return cmd_line;
>  }
>  
>  /*
> @@ -189,7 +189,7 @@ static void walk_path(QOSGraphNode *orig_path, int len)
>      g_free(path_str);
>  }
>  
> -static const char *qos_get_cmdline(FuzzTarget *t)
> +static GString *qos_get_cmdline(FuzzTarget *t)
>  {
>      /*
>       * Set a global variable that we use to identify the qos_path for our
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>

... and queued to my "qtest-next" branch.

 Thanks,
  Thomas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]