[PATCH] wayland-server: Fix null pointer dereferencing

Giulio Camuffo giuliocamuffo at gmail.com
Thu Jul 16 00:22:44 PDT 2015


2015-07-16 9:27 GMT+03:00 Ashim <ashim.shah at samsung.com>:
> Initialising 'wl_client *client = NULL' and checking 'resource' for NULL and returning if found.
> This patch will avoid dereferencing of 'resource' if NULL

I think in this case passing a NULL resource to
wl_resource_post_error() is a programming mistake, and it should
crash. If there is the possibility somewhere that the resource is null
it should be checked before calling wl_resource_post_error(), imho.

--
Giulio

>
> Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=91356
>
> Signed-off-by: Ashim <ashim.shah at samsung.com>
> ---
>  src/wayland-server.c |    7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/src/wayland-server.c b/src/wayland-server.c
> index 0f04f66..2a0d19c 100644
> --- a/src/wayland-server.c
> +++ b/src/wayland-server.c
> @@ -207,7 +207,7 @@ WL_EXPORT void
>  wl_resource_post_error(struct wl_resource *resource,
>                        uint32_t code, const char *msg, ...)
>  {
> -       struct wl_client *client = resource->client;
> +       struct wl_client *client = NULL;
>         char buffer[128];
>         va_list ap;
>
> @@ -215,6 +215,11 @@ wl_resource_post_error(struct wl_resource *resource,
>         vsnprintf(buffer, sizeof buffer, msg, ap);
>         va_end(ap);
>
> +       if (resource == NULL)
> +               return;
> +       else
> +               client = resource->client;
> +
>         client->error = 1;
>
>         /*
> --
> 1.7.9.5
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list