[Spice-devel] [usbredir v2] usbredirhost: avoid access to null pointer
Victor Toso
victortoso at redhat.com
Sat Aug 6 12:07:27 UTC 2016
Hi,
On Thu, Aug 04, 2016 at 02:19:29PM +0200, Pavel Grunt wrote:
> 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>
Thanks, pushed as
https://cgit.freedesktop.org/spice/usbredir/commit/?id=ac80a5971c6318d73d5fba4b5f13d3a9389558c9
> > ---
> > 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