BUG/MEDIUM: tools: Fix inet_ntop usage in sa2str

The given size must be the size of the destination buffer, not the size of the
(binary) address representation.

This fixes GitHub issue #1599.

The bug was introduced in 92149f9a82 which is in
2.4+. The fix must be backported there.
This commit is contained in:
Tim Duesterhus 2022-05-22 13:06:27 +02:00 committed by Willy Tarreau
parent 147eeb2ef3
commit 162f0875ad

View File

@ -1375,7 +1375,7 @@ char * sa2str(const struct sockaddr_storage *addr, int port, int map_ports)
default:
return NULL;
}
inet_ntop(addr->ss_family, ptr, buffer, get_addr_len(addr));
inet_ntop(addr->ss_family, ptr, buffer, sizeof(buffer));
if (map_ports)
return memprintf(&out, "%s:%+d", buffer, port);
else