diff options
author | Pierre Ossman <ossman@cendio.se> | 2023-01-17 16:49:01 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2023-02-04 14:03:13 +0100 |
commit | 7f20bff3561dd942a39ce3ecf604c7c9673bad37 (patch) | |
tree | 3cae1d8cbd0938a595740882c6c2c95572dc5477 /common | |
parent | 741300728a889b4ccaec35bd57efb072018c860c (diff) | |
download | tigervnc-7f20bff3561dd942a39ce3ecf604c7c9673bad37.tar.gz tigervnc-7f20bff3561dd942a39ce3ecf604c7c9673bad37.zip |
Remove unneeded CharArray:s
Avoid complicating things by moving things in to a second buffer here as
there is no need for it.
Diffstat (limited to 'common')
-rw-r--r-- | common/network/TcpSocket.cxx | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/common/network/TcpSocket.cxx b/common/network/TcpSocket.cxx index 8424a4d6..cc82faef 100644 --- a/common/network/TcpSocket.cxx +++ b/common/network/TcpSocket.cxx @@ -711,21 +711,18 @@ TcpFilter::Pattern TcpFilter::parsePattern(const char* p) { } char* TcpFilter::patternToStr(const TcpFilter::Pattern& p) { - rfb::CharArray addr; - char buffer[INET6_ADDRSTRLEN + 2]; + char addr[INET6_ADDRSTRLEN + 2]; if (p.address.u.sa.sa_family == AF_INET) { getnameinfo(&p.address.u.sa, sizeof(p.address.u.sin), - buffer, sizeof (buffer), NULL, 0, NI_NUMERICHOST); - addr.buf = rfb::strDup(buffer); + addr, sizeof(addr), NULL, 0, NI_NUMERICHOST); } else if (p.address.u.sa.sa_family == AF_INET6) { - buffer[0] = '['; + addr[0] = '['; getnameinfo(&p.address.u.sa, sizeof(p.address.u.sin6), - buffer + 1, sizeof (buffer) - 2, NULL, 0, NI_NUMERICHOST); - strcat(buffer, "]"); - addr.buf = rfb::strDup(buffer); + addr + 1, sizeof(addr) - 2, NULL, 0, NI_NUMERICHOST); + strcat(addr, "]"); } else - addr.buf = rfb::strDup(""); + addr[0] = '\0'; char action; switch (p.action) { @@ -735,15 +732,15 @@ char* TcpFilter::patternToStr(const TcpFilter::Pattern& p) { case Query: action = '?'; break; }; size_t resultlen = (1 // action - + strlen (addr.buf) // address + + strlen (addr) // address + 1 // slash + 3 // prefix length, max 128 + 1); // terminating nul char* result = new char[resultlen]; - if (addr.buf[0] == '\0') + if (addr[0] == '\0') snprintf(result, resultlen, "%c", action); else - snprintf(result, resultlen, "%c%s/%u", action, addr.buf, p.prefixlen); + snprintf(result, resultlen, "%c%s/%u", action, addr, p.prefixlen); return result; } |