[PATCH wayland] connection: Clear correct args when clearing fds to -1

Pekka Paalanen ppaalanen at gmail.com
Mon Jan 22 08:07:24 UTC 2018


On Fri, 19 Jan 2018 15:20:31 -0600
Derek Foreman <derekf at osg.samsung.com> wrote:

> commit 52609ddf79a96fee0465006e2c6339a3a5d23a87 was intended to
> set fds to -1 in the arg list, however it failed to account for
> version information at the start of signatures.

Heh, yeah, I too was completely baffled why that commit would have
broken anything, but as soon as I saw the title of this patch, it hit
me. It's not just version info but the nullable '?' marker as well.

> Most noticably, this broke mesa's create_prime_buffer by setting
> width to -1 instead of the fd, as the width was the argument
> following the fd, and the version was one byte long.
> 
> This should close https://bugs.kde.org/show_bug.cgi?id=389200
> 
> Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
> ---
>  src/connection.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/src/connection.c b/src/connection.c
> index 6f83bab..5d5711f 100644
> --- a/src/connection.c
> +++ b/src/connection.c
> @@ -533,10 +533,13 @@ wl_argument_from_va_list(const char *signature, union wl_argument *args,
>  static void
>  wl_closure_clear_fds(struct wl_closure *closure)
>  {
> +	const char *signature = closure->message->signature;
> +	struct argument_details arg;
>  	int i;
>  
> -	for (i = 0; closure->message->signature[i]; i++) {
> -		if (closure->message->signature[i] == 'h')
> +	for (i = 0; i < closure->count; i++) {
> +		signature = get_next_argument(signature, &arg);
> +		if (arg.type == 'h')
>  			closure->args[i].h = -1;
>  	}
>  }

Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20180122/6197eaa3/attachment.sig>


More information about the wayland-devel mailing list