]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: tools: Fix `inet_ntop` usage in sa2str
authorTim Duesterhus <tim@bastelstu.be>
Sun, 22 May 2022 11:06:27 +0000 (13:06 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 23 May 2022 06:45:31 +0000 (08:45 +0200)
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.

src/tools.c

index 4c93e1e82f86de25ea0f91ff17798746f844d93f..79d1d5c9b193bff0790b17008cff6627cee0a580 100644 (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