diff options
author | Demi Marie Obenour <demiobenour@gmail.com> | 2022-12-15 14:48:13 -0500 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-03-19 18:07:21 +0000 |
commit | 232a11a947564762689e63c3a6603d3f956f696d (patch) | |
tree | 8f08d28ca038f8270acb4450a69ca2308fef52a4 | |
parent | b898f415e7c31de5b4beb06b22a5498049852e53 (diff) |
DISPLAY starting with unix: or / is always a socket path
Do not consider anything else in this case.
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
-rw-r--r-- | Xtrans.c | 48 |
1 files changed, 25 insertions, 23 deletions
@@ -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. |