|
Jan F |
5daee1 |
diff -up openssh-5.3p1/channels.c.bz595935 openssh-5.3p1/channels.c
|
|
Jan F |
5daee1 |
--- openssh-5.3p1/channels.c.bz595935 2010-08-12 14:19:28.000000000 +0200
|
|
Jan F |
5daee1 |
+++ openssh-5.3p1/channels.c 2010-08-12 14:33:51.000000000 +0200
|
|
Jan F |
5daee1 |
@@ -3185,7 +3185,7 @@ x11_create_display_inet(int x11_display_
|
|
Jan F. Chadima |
2664a6 |
}
|
|
Jan F. Chadima |
2664a6 |
|
|
Jan F. Chadima |
2664a6 |
static int
|
|
Jan F. Chadima |
2664a6 |
-connect_local_xsocket_path(const char *pathname)
|
|
Jan F. Chadima |
2664a6 |
+connect_local_xsocket_path(const char *pathname, int len)
|
|
Jan F. Chadima |
2664a6 |
{
|
|
Jan F. Chadima |
2664a6 |
int sock;
|
|
Jan F. Chadima |
2664a6 |
struct sockaddr_un addr;
|
|
Jan F |
5daee1 |
@@ -3195,11 +3195,14 @@ connect_local_xsocket_path(const char *p
|
|
Jan F. Chadima |
2664a6 |
error("socket: %.100s", strerror(errno));
|
|
Jan F. Chadima |
2664a6 |
memset(&addr, 0, sizeof(addr));
|
|
Jan F. Chadima |
2664a6 |
addr.sun_family = AF_UNIX;
|
|
Jan F. Chadima |
2664a6 |
- strlcpy(addr.sun_path, pathname, sizeof addr.sun_path);
|
|
Jan F |
5daee1 |
- if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) == 0)
|
|
Jan F. Chadima |
2664a6 |
+ if (len <= 0)
|
|
Jan F. Chadima |
2664a6 |
+ return -1;
|
|
Jan F. Chadima |
2664a6 |
+ if (len > sizeof addr.sun_path)
|
|
Jan F. Chadima |
2664a6 |
+ len = sizeof addr.sun_path;
|
|
Jan F |
5daee1 |
+ memcpy(addr.sun_path, pathname, len);
|
|
Jan F |
5daee1 |
+ if (connect(sock, (struct sockaddr *)&addr, sizeof addr - (sizeof addr.sun_path - len) ) == 0)
|
|
Jan F. Chadima |
2664a6 |
return sock;
|
|
Jan F. Chadima |
2664a6 |
close(sock);
|
|
Jan F |
5daee1 |
- error("connect %.100s: %.100s", addr.sun_path, strerror(errno));
|
|
Jan F |
5daee1 |
return -1;
|
|
Jan F |
5daee1 |
}
|
|
Jan F |
5daee1 |
|
|
Jan F |
5daee1 |
@@ -3207,8 +3210,21 @@ static int
|
|
Jan F. Chadima |
a3dee6 |
connect_local_xsocket(u_int dnr)
|
|
Jan F. Chadima |
a3dee6 |
{
|
|
Jan F. Chadima |
a3dee6 |
char buf[1024];
|
|
Jan F. Chadima |
2664a6 |
- snprintf(buf, sizeof buf, _PATH_UNIX_X, dnr);
|
|
Jan F. Chadima |
2664a6 |
- return connect_local_xsocket_path(buf);
|
|
Jan F. Chadima |
2664a6 |
+ int len;
|
|
Jan F. Chadima |
a3dee6 |
+#ifdef linux
|
|
Jan F. Chadima |
a3dee6 |
+ int ret;
|
|
Jan F. Chadima |
a3dee6 |
+#endif
|
|
Jan F. Chadima |
2664a6 |
+ len = snprintf(buf + 1, sizeof (buf) - 1, _PATH_UNIX_X, dnr);
|
|
Jan F. Chadima |
a3dee6 |
+#ifdef linux
|
|
Jan F. Chadima |
a3dee6 |
+ /* try abstract socket first */
|
|
Jan F. Chadima |
a3dee6 |
+ buf[0] = '\0';
|
|
Jan F. Chadima |
2664a6 |
+ if ((ret = connect_local_xsocket_path(buf, len + 1)) >= 0)
|
|
Jan F. Chadima |
a3dee6 |
+ return ret;
|
|
Jan F. Chadima |
a3dee6 |
+#endif
|
|
Jan F |
5daee1 |
+ if ((ret = connect_local_xsocket_path(buf + 1, len)) >= 0)
|
|
Jan F |
5daee1 |
+ return ret;
|
|
Jan F |
5daee1 |
+ error("connect %.100s: %.100s", buf + 1, strerror(errno));
|
|
Jan F |
5daee1 |
+ return -1;
|
|
Jan F. Chadima |
a3dee6 |
}
|
|
Jan F. Chadima |
41a56c |
|
|
Jan F. Chadima |
2664a6 |
int
|