diff options
author | Matthieu Herrb <matthieu@herrb.eu> | 2024-05-05 11:47:32 +0200 |
---|---|---|
committer | Matthieu Herrb <matthieu@herrb.eu> | 2024-05-05 11:47:32 +0200 |
commit | ea7116003a79a774786ce833de77496b05e136e2 (patch) | |
tree | 463c3a0a73c97f9b92f0d4e82ff1c9922d684550 /Xtrans.c | |
parent | 6ac755aff400873a2a62f18948f32a14d8725bd8 (diff) | |
parent | 656d27ed32af4082e8062c1d7c42b65ea3a6b80f (diff) |
Merge remote-tracking branch 'origin/master' into obsd
Diffstat (limited to 'Xtrans.c')
-rw-r--r-- | Xtrans.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -204,8 +204,9 @@ TRANS(ParseAddress) (const char *address, char *mybuf, *tmpptr = NULL; const char *_protocol = NULL; - char *_host, *_port; + const char *_host, *_port; char hostnamebuf[256]; + char *_host_buf; int _host_len; size_t len; @@ -294,7 +295,7 @@ TRANS(ParseAddress) (const char *address, /* Get the host part */ - _host = mybuf; + _host = _host_buf = mybuf; if ((mybuf = strrchr (mybuf,':')) == NULL) { @@ -317,10 +318,10 @@ TRANS(ParseAddress) (const char *address, /* hostname in IPv6 [numeric_addr]:0 form? */ else if ( (_host_len > 3) && ((strcmp(_protocol, "tcp") == 0) || (strcmp(_protocol, "inet6") == 0)) - && (*_host == '[') && (*(_host + _host_len - 1) == ']') ) { + && (_host_buf[0] == '[') && (_host_buf[_host_len - 1] == ']') ) { struct sockaddr_in6 sin6; - *(_host + _host_len - 1) = '\0'; + _host_buf[_host_len - 1] = '\0'; /* Verify address is valid IPv6 numeric form */ if (inet_pton(AF_INET6, _host + 1, &sin6) == 1) { @@ -329,7 +330,7 @@ TRANS(ParseAddress) (const char *address, _protocol = "inet6"; } else { /* It's not, restore it just in case some other code can use it. */ - *(_host + _host_len - 1) = ']'; + _host_buf[_host_len - 1] = ']'; } } #endif @@ -1351,7 +1352,7 @@ int TRANS(GetHostname) (char *buf, int maxlen) uname (&name); len = strlen (name.nodename); if (len >= maxlen) len = maxlen - 1; - strncpy (buf, name.nodename, len); + memcpy (buf, name.nodename, len); buf[len] = '\0'; #else buf[0] = '\0'; |