char *command;
int maxsize = *datalen;
char *localbuf;
+ int proto = -1;
- command = dupprintf("xauth list %s 2>/dev/null", display);
+ /*
+ * Normally we should run `xauth list DISPLAYNAME'. However,
+ * there's an oddity when the display is local: the display
+ * `localhost:0' (or `:0') should become just `:0'.
+ */
+ if (!strncmp(display, "localhost:", 10))
+ command = dupprintf("xauth list %s 2>/dev/null", display+9);
+ else
+ command = dupprintf("xauth list %s 2>/dev/null", display);
fp = popen(command, "r");
sfree(command);
if (!fp)
return; /* assume no auth */
- localbuf = smalloc(maxsize);
+ localbuf = snewn(maxsize, char);
while (1) {
/*
* Read a line from stdin, and attempt to parse it into a
* display name (ignored), auth protocol, and auth string.
*/
- int c, i, hexdigit, proto;
+ int c, i, hexdigit;
char protoname[64];
/* Skip the display name. */