From: Michal Nowak Date: Thu, 6 Aug 2026 08:53:55 +0000 (+0200) Subject: Fix -Wformat-truncation warning in totext_in_wks() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ce2337dff7e5adfdea001b61fb6ebdb9583a57f;p=thirdparty%2Fbind9.git Fix -Wformat-truncation warning in totext_in_wks() GCC 16 at -O3 rejects the WKS port bitmap loop with: error: '%u' directive output may be truncated writing between 1 and 10 bytes into a region of size 6 [-Werror=format-truncation=] The INSIST() bounding the bitmap length keeps the printed port below 65536, but 'sr' escapes into inet_totext(), so the compiler must assume every later call can clobber it and loses the range it needs to prove the port fits. Printing the port with '%hu' states the 16-bit bound in the format string instead of leaving it to be re-derived from the bitmap length. --- diff --git a/lib/dns/rdata/in_1/wks_11.c b/lib/dns/rdata/in_1/wks_11.c index 8c980d4bc3c..0a49e0be197 100644 --- a/lib/dns/rdata/in_1/wks_11.c +++ b/lib/dns/rdata/in_1/wks_11.c @@ -193,8 +193,8 @@ totext_in_wks(ARGS_TOTEXT) { for (j = 0; j < 8; j++) { if ((sr.base[i] & (0x80 >> j)) != 0) { { - snprintf(buf, sizeof(buf), "%u", - i * 8 + j); + snprintf(buf, sizeof(buf), + "%hu", i * 8 + j); RETERR(str_totext(" ", target)); RETERR(str_totext(buf, target)); }