From: Tim Duesterhus Date: Sun, 22 May 2022 11:06:27 +0000 (+0200) Subject: BUG/MEDIUM: tools: Fix `inet_ntop` usage in sa2str X-Git-Tag: v2.6-dev12~148 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=162f0875adbe1418ef3cabf68bf1c70ba94e4f56;p=thirdparty%2Fhaproxy.git 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 92149f9a82a9b55c598f1cc815bc330c555f3561 which is in 2.4+. The fix must be backported there. --- diff --git a/src/tools.c b/src/tools.c index 4c93e1e82f..79d1d5c9b1 100644 --- a/src/tools.c +++ b/src/tools.c @@ -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