<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On 17 July 2014 19:54, Jasper St. Pierre <span dir="ltr"><<a href="mailto:jstpierre@mecheye.net" target="_blank">jstpierre@mecheye.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This allows us to return the display name to the client in a new API.<br>
---<br>
 src/wayland-server.c | 3 +++<br>
 1 file changed, 3 insertions(+)<br>
<br>
diff --git a/src/wayland-server.c b/src/wayland-server.c<br>
index 5c0e84f..55b3e25 100644<br>
--- a/src/wayland-server.c<br>
+++ b/src/wayland-server.c<br>
@@ -63,6 +63,7 @@ struct wl_socket {<br>
        char lock_addr[UNIX_PATH_MAX + LOCK_SUFFIXLEN];<br>
        struct wl_list link;<br>
        struct wl_event_source *source;<br>
+       char *display_name;<br>
 };<br>
<br>
 struct wl_client {<br>
@@ -1082,6 +1083,8 @@ wl_socket_init_for_display_name(struct wl_socket *s, const char *name)<br>
        name_size = snprintf(s->addr.sun_path, sizeof s->addr.sun_path,<br>
                             "%s/%s", runtime_dir, name) + 1;<br>
<br>
+       s->display_name = (s->addr.sun_path + sizeof s->addr.sun_path) - strlen(name);<br>
+<br></blockquote><div> <br></div><div>sun_path is an array so sizeof s->addr.sun_path is around 108 I think? That means:<br><br>sun_path = [/run/user/1000/wayland-0\0............................................................ ]<br>
<br></div><div>sizeof sun_path - strlen("wayland-0") = is pointing somewhere here     ^<br></div><div><br>I believe you wanted use name_size or strlen(name). This works for me:<br>    s->display_name = (s->addr.sun_path + name_size - 1) - strlen(name);</div>
<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
        assert(name_size > 0);<br>
        if (name_size > (int)sizeof s->addr.sun_path) {<br>
                wl_log("error: socket path \"%s/%s\" plus null terminator"<br>
<span class=""><font color="#888888">--<br>
2.0.1<br>
<br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br></font></span></blockquote><div><br></div><div>Regards,<br>Marek <br>
</div></div><br></div></div>