From 232a11a947564762689e63c3a6603d3f956f696d Mon Sep 17 00:00:00 2001 From: Demi Marie Obenour Date: Thu, 15 Dec 2022 14:48:13 -0500 Subject: DISPLAY starting with unix: or / is always a socket path Do not consider anything else in this case. Signed-off-by: Demi Marie Obenour --- Xtrans.c | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/Xtrans.c b/Xtrans.c index b2b98a2..12eefe8 100644 --- a/Xtrans.c +++ b/Xtrans.c @@ -202,14 +202,36 @@ TRANS(ParseAddress) (const char *address, * If a "::" is found then assume DNET. */ - char *mybuf, *tmpptr; - const char *_protocol; + char *mybuf, *tmpptr = NULL; + const char *_protocol = NULL; char *_host, *_port; char hostnamebuf[256]; int _host_len; prmsg (3,"ParseAddress(%s)\n", address); + /* First, check for AF_UNIX socket paths */ + if (address[0] == '/') { + _protocol = "local"; + _host = ""; + _port = address; + } else +#ifdef HAVE_LAUNCHD + /* launchd sockets will look like 'local//tmp/launch-XgkNns/:0' */ + if(!strncmp(address,"local//",7)) { + _protocol="local"; + _host=""; + _port=address+6; + } else +#endif + if (!strncmp(address, "unix:", 5)) { + _protocol = "local"; + _host = ""; + _port = address + 5; + } + if (_protocol) + goto done_parsing; + /* Copy the string so it can be changed */ tmpptr = mybuf = strdup (address); @@ -331,27 +353,7 @@ TRANS(ParseAddress) (const char *address, */ #endif - if (address != NULL) { - if (address[0] == '/') { - _protocol = "local"; - _host = ""; - _port = address; - } else -#ifdef HAVE_LAUNCHD - /* launchd sockets will look like 'local//tmp/launch-XgkNns/:0' */ - if(!strncmp(address,"local//",7)) { - _protocol="local"; - _host=""; - _port=address+6; - } else -#endif - if (!strncmp(address, "unix:", 5)) { - _protocol = "local"; - _host = ""; - _port = address + 5; - } - } - +done_parsing: /* * Now that we have all of the components, allocate new * string space for them. -- cgit v1.2.1