[Spice-devel] [usbredir v2] usbredirhost: avoid access to null pointer
Pavel Grunt
pgrunt at redhat.com
Thu Aug 4 12:19:29 UTC 2016
On Thu, 2016-08-04 at 13:57 +0200, Victor Toso wrote:
> ERROR() is a wrapper for va_log() which takes usbredirhost* as first
> argument. We can't use it if host == NULL. Changing to fprintf to not
> fail the function silently.
>
> This was catched by coverity:
> 3. usbredir-0.7.1/usbredirhost/usbredirhost.c:1412: var_deref_model:
> Passing null pointer "host" to "va_log", which dereferences it.
> 4. usbredir-0.7.1/usbredirhost/usbredirhost.c:163:5: deref_parm:
> Directly dereferencing parameter "host".
> # 161| int n;
> # 162|
> # 163|-> if (level > host->verbose) {
> # 164| return;
> # 165| }
Acked-by: Pavel Grunt <pgrunt at redhat.com>
> ---
> usbredirhost/usbredirhost.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/usbredirhost/usbredirhost.c b/usbredirhost/usbredirhost.c
> index 3e80677..857e821 100644
> --- a/usbredirhost/usbredirhost.c
> +++ b/usbredirhost/usbredirhost.c
> @@ -1409,7 +1409,7 @@ void usbredirhost_set_buffered_output_size_cb(struct
> usbredirhost *host,
> usbredirhost_buffered_output_size buffered_output_size_func)
> {
> if (!host) {
> - ERROR("invalid usbredirhost");
> + fprintf(stderr, "%s: invalid usbredirhost", __func__);
the original code was always prepending "usbredirhost: ", function name is
probably more helpful (__func__ is C99, but I guess it is ok)
Pavel
> return;
> }
>
More information about the Spice-devel
mailing list