Re: [PATCH 1/2] BUG/MEDIUM: tools: Fix `inet_ntop` usage in sa2str

2022-05-23 Thread Thayne McCombs


Thanks for catching that.



Re: [PATCH 1/2] BUG/MEDIUM: tools: Fix `inet_ntop` usage in sa2str

2022-05-22 Thread Willy Tarreau
On Sun, May 22, 2022 at 01:06:27PM +0200, Tim Duesterhus wrote:
> 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.

Ah good catch, merged, thanks Tim!
Willy



[PATCH 1/2] BUG/MEDIUM: tools: Fix `inet_ntop` usage in sa2str

2022-05-22 Thread Tim Duesterhus
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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/tools.c b/src/tools.c
index 9e629e5bd..b9a1121c6 100644
--- a/src/tools.c
+++ b/src/tools.c
@@ -1374,7 +1374,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
-- 
2.36.1