summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorMaciej Żenczykowski <maze@google.com>2023-10-15 17:50:36 +0000
committerMaciej Żenczykowski <maze@google.com>2023-10-16 17:30:59 +0000
commitd8a146be4514e63c568efa89b65110694530e42a (patch)
treebfd64ca7cfcfcb0da3799e0c38e8a4fd4c82264a /server
parent7681bf607147844648381879044a97ceb300e899 (diff)
downloadnetd-d8a146be4514e63c568efa89b65110694530e42a.tar.gz
FwMarkServer: include space for scope
bionic/libc/dns/net/getnameinfo.c does return scope... Example IPv6 addresses (IPv4 is comparatively short of course) 1111:2222:3333:4444:5555:6666:7777:8888\0 <= 8*5 = 40 1111:2222:3333:4444:5555:6666:123.123.123.123\0 <= 6*5 + 4*4 = 46 fe80:2222:3333:4444:5555:6666:7777:8888%DEV...\0 <= 8*5 + 16 = 56 it's not clear whether 46 + 16 == 62 case can happen as well... ping6 fe80:1111:2222:3333:4444:5555:123.123.123.123%enx00112233445566 does work (as in parse the address), [even though more normal is fe80::1122:33ff:fe44:5566%rmnet0] note: scope u32 can be numeric too, but that's only 10 characters FYI we have: // actually too short (ie. no space for scope for link local ips) INET6_ADDRSTRLEN == 46 // Max Linux interface name is 15 char + null IFNAMSIZ == 16 Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I6af19305e9ca13b2a633b8be4fb5533cd67d19ea
Diffstat (limited to 'server')
-rw-r--r--server/FwmarkServer.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/server/FwmarkServer.cpp b/server/FwmarkServer.cpp
index c97ae774..7c2b2270 100644
--- a/server/FwmarkServer.cpp
+++ b/server/FwmarkServer.cpp
@@ -212,8 +212,10 @@ int FwmarkServer::processClient(SocketClient* client, int* socketFd) {
mEventReporter->getNetdEventListener();
if (netdEventListener != nullptr) {
- char addrstr[INET6_ADDRSTRLEN];
- char portstr[sizeof("65536")];
+ char addrstr[INET6_ADDRSTRLEN + IFNAMSIZ]; // ipv6 address + optional %scope
+ char portstr[sizeof("65535")];
+ static_assert(sizeof(addrstr) >= 62);
+ static_assert(sizeof(portstr) >= 6);
const int ret = getnameinfo(&connectInfo.addr.s, sizeof(connectInfo.addr.s),
addrstr, sizeof(addrstr), portstr, sizeof(portstr),
NI_NUMERICHOST | NI_NUMERICSERV);