[PATCH wayland 5/6] server: Save the display name in the wl_socket

Marek Chalupa mchqwerty at gmail.com
Fri Jul 18 01:39:24 PDT 2014


On 17 July 2014 19:54, Jasper St. Pierre <jstpierre at mecheye.net> wrote:

> This allows us to return the display name to the client in a new API.
> ---
>  src/wayland-server.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/src/wayland-server.c b/src/wayland-server.c
> index 5c0e84f..55b3e25 100644
> --- a/src/wayland-server.c
> +++ b/src/wayland-server.c
> @@ -63,6 +63,7 @@ struct wl_socket {
>         char lock_addr[UNIX_PATH_MAX + LOCK_SUFFIXLEN];
>         struct wl_list link;
>         struct wl_event_source *source;
> +       char *display_name;
>  };
>
>  struct wl_client {
> @@ -1082,6 +1083,8 @@ wl_socket_init_for_display_name(struct wl_socket *s,
> const char *name)
>         name_size = snprintf(s->addr.sun_path, sizeof s->addr.sun_path,
>                              "%s/%s", runtime_dir, name) + 1;
>
> +       s->display_name = (s->addr.sun_path + sizeof s->addr.sun_path) -
> strlen(name);
> +
>

sun_path is an array so sizeof s->addr.sun_path is around 108 I think? That
means:

sun_path =
[/run/user/1000/wayland-0\0............................................................
]

sizeof sun_path - strlen("wayland-0") = is pointing somewhere here     ^

I believe you wanted use name_size or strlen(name). This works for me:
    s->display_name = (s->addr.sun_path + name_size - 1) - strlen(name);

        assert(name_size > 0);
>         if (name_size > (int)sizeof s->addr.sun_path) {
>                 wl_log("error: socket path \"%s/%s\" plus null terminator"
> --
> 2.0.1
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>

Regards,
Marek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20140718/8bc5bd7a/attachment.html>


More information about the wayland-devel mailing list