Package: src:libxcb
Version: 1.17.0-1
Tags: patch
After getting rid of PATH_MAX and MAXPATHLEN in release 1.7 dated
2010-08-13, it seem to have been reintroduced in the current code base,
making it fail to build on Hurd. I propose the following patch to avoid
the use of an arbitrary and for at least some file systems wrong
hardcoded limit to some paths checked.
diff --git a/src/xcb_util.c b/src/xcb_util.c
index 5124d14..def2264 100644
--- a/src/xcb_util.c
+++ b/src/xcb_util.c
@@ -104,35 +104,46 @@ static int _xcb_parse_display_path_to_socket(const char
*name, char **host, char
int *displayp, int *screenp)
{
struct stat sbuf;
- char path[PATH_MAX];
- size_t len;
+ char *path = NULL;
int _screen = 0, res;
- len = strlen(name);
- if (len >= sizeof(path))
- return 0;
- memcpy(path, name, len + 1);
- res = stat(path, &sbuf);
+ res = stat(name, &sbuf);
if (0 != res) {
unsigned long lscreen;
char *dot, *endptr;
if (res != -1 || (errno != ENOENT && errno != ENOTDIR))
return 0;
+ path = strdup(name);
dot = strrchr(path, '.');
- if (!dot || dot[1] < '1' || dot[1] > '9')
+ if (!dot || dot[1] < '1' || dot[1] > '9') {
+ free(path);
+ path = NULL;
return 0;
+ }
*dot = '\0';
errno = 0;
lscreen = strtoul(dot + 1, &endptr, 10);
- if (lscreen > INT_MAX || !endptr || *endptr || errno)
+ if (lscreen > INT_MAX || !endptr || *endptr || errno) {
+ free(path);
+ path = NULL;
return 0;
- if (0 != stat(path, &sbuf))
+ }
+ if (0 != stat(path, &sbuf)) {
+ free(path);
+ path = NULL;
return 0;
+ }
_screen = (int)lscreen;
}
if (host) {
- *host = strdup(path);
+ if (path) {
+ *host = strdup(path);
+ free(path);
+ path = NULL;
+ } else {
+ *host = strdup(name);
+ }
if (!*host)
return 0;
}
@@ -285,15 +296,19 @@ static int _xcb_open(const char *host, char *protocol,
const int display)
if (is_system_labeled())
{
const char *tsol_base = "/var/tsol/doors/.X11-unix/X";
- char tsol_socket[PATH_MAX];
+ char *tsol_socket;
struct stat sbuf;
-
+ size_t needed = snprintf(NULL, 0, "%s%d", tsol_base, display) + 1;
+ tsol_socket = malloc(needed);
snprintf(tsol_socket, sizeof(tsol_socket), "%s%d", tsol_base,
display);
- if (stat(tsol_socket, &sbuf) == 0)
+ if (stat(tsol_socket, &sbuf) == 0) {
base = tsol_base;
- else if (errno != ENOENT)
+ free(tsol_socket);
+ } else if (errno != ENOENT) {
+ free(tsol_socket);
return 0;
+ }
}
#endif
--
Happy hacking
Petter Reinholdtsen