From: Tim Duesterhus Date: Mon, 23 May 2022 07:30:49 +0000 (+0200) Subject: CLEANUP: tools: Crash if inet_ntop fails due to ENOSPC in sa2str X-Git-Tag: v2.6-dev12~147 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=22535a56a785d45dd0537e36eb90921662efd1dd;p=thirdparty%2Fhaproxy.git CLEANUP: tools: Crash if inet_ntop fails due to ENOSPC in sa2str This is impossible, because we pass a destination buffer that is appropriately sized to hold an IPv6 address. This is related to GitHub issue #1599. --- diff --git a/src/tools.c b/src/tools.c index 79d1d5c9b1..4ecbdc4d71 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1375,7 +1375,10 @@ char * sa2str(const struct sockaddr_storage *addr, int port, int map_ports) default: return NULL; } - inet_ntop(addr->ss_family, ptr, buffer, sizeof(buffer)); + if (inet_ntop(addr->ss_family, ptr, buffer, sizeof(buffer)) == NULL) { + BUG_ON(errno == ENOSPC); + return NULL; + } if (map_ports) return memprintf(&out, "%s:%+d", buffer, port); else