|
|
9070b3 |
diff -up openssh-7.2p2/channels.c.x11 openssh-7.2p2/channels.c
|
|
|
9070b3 |
--- openssh-7.2p2/channels.c.x11 2016-03-09 19:04:48.000000000 +0100
|
|
|
9070b3 |
+++ openssh-7.2p2/channels.c 2016-06-03 10:42:04.775164520 +0200
|
|
|
9070b3 |
@@ -3990,21 +3990,24 @@ x11_create_display_inet(int x11_display_
|
|
|
9070b3 |
}
|
|
|
9070b3 |
|
|
|
9070b3 |
static int
|
|
|
9070b3 |
-connect_local_xsocket_path(const char *pathname)
|
|
|
9070b3 |
+connect_local_xsocket_path(const char *pathname, int len)
|
|
|
9070b3 |
{
|
|
|
9070b3 |
int sock;
|
|
|
9070b3 |
struct sockaddr_un addr;
|
|
|
9070b3 |
|
|
|
9070b3 |
+ if (len <= 0)
|
|
|
9070b3 |
+ return -1;
|
|
|
9070b3 |
sock = socket(AF_UNIX, SOCK_STREAM, 0);
|
|
|
9070b3 |
if (sock == -1)
|
|
|
9070b3 |
error("socket: %.100s", strerror(errno));
|
|
|
9070b3 |
memset(&addr, 0, sizeof(addr));
|
|
|
9070b3 |
addr.sun_family = AF_UNIX;
|
|
|
9070b3 |
- strlcpy(addr.sun_path, pathname, sizeof addr.sun_path);
|
|
|
9070b3 |
- if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) == 0)
|
|
|
9070b3 |
+ if (len > sizeof addr.sun_path)
|
|
|
9070b3 |
+ len = sizeof addr.sun_path;
|
|
|
9070b3 |
+ memcpy(addr.sun_path, pathname, len);
|
|
|
9070b3 |
+ if (connect(sock, (struct sockaddr *)&addr, sizeof addr - (sizeof addr.sun_path - len) ) == 0)
|
|
|
9070b3 |
return sock;
|
|
|
9070b3 |
close(sock);
|
|
|
9070b3 |
- error("connect %.100s: %.100s", addr.sun_path, strerror(errno));
|
|
|
9070b3 |
return -1;
|
|
|
9070b3 |
}
|
|
|
9070b3 |
|
|
|
9070b3 |
@@ -4012,8 +4015,18 @@ static int
|
|
|
9070b3 |
connect_local_xsocket(u_int dnr)
|
|
|
9070b3 |
{
|
|
|
9070b3 |
char buf[1024];
|
|
|
9070b3 |
- snprintf(buf, sizeof buf, _PATH_UNIX_X, dnr);
|
|
|
9070b3 |
- return connect_local_xsocket_path(buf);
|
|
|
9070b3 |
+ int len, ret;
|
|
|
9070b3 |
+ len = snprintf(buf + 1, sizeof (buf) - 1, _PATH_UNIX_X, dnr);
|
|
|
9070b3 |
+#ifdef linux
|
|
|
9070b3 |
+ /* try abstract socket first */
|
|
|
9070b3 |
+ buf[0] = '\0';
|
|
|
9070b3 |
+ if ((ret = connect_local_xsocket_path(buf, len + 1)) >= 0)
|
|
|
9070b3 |
+ return ret;
|
|
|
9070b3 |
+#endif
|
|
|
9070b3 |
+ if ((ret = connect_local_xsocket_path(buf + 1, len)) >= 0)
|
|
|
9070b3 |
+ return ret;
|
|
|
9070b3 |
+ error("connect %.100s: %.100s", buf + 1, strerror(errno));
|
|
|
9070b3 |
+ return -1;
|
|
|
9070b3 |
}
|
|
|
9070b3 |
|
|
|
9070b3 |
#ifdef __APPLE__
|