From 8ce39fdcb1ccb3291eaf44fccc80236f691e1e3d Mon Sep 17 00:00:00 2001 From: Michal Nowak Date: Thu, 11 Jun 2026 11:39:14 +0000 Subject: [PATCH] Fix a false positive compiler warning/error on Alpine 3.24 On Alpine Linux 3.24, GCC 15 with fortify-headers produces a compiler warning when building bin/nsupdate/nsupdate.c: In function 'fgets', inlined from 'get_next_command' at ../bin/nsupdate/nsupdate.c:2414:13: /usr/include/fortify/stdio.h:48:16: error: 'cmdlinebuf' may be used uninitialized [-Werror=maybe-uninitialized] 48 | return __orig_fgets(__s, __n, __f); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/fortify/stdio.h:42:1: note: in a call to '*fgets' declared with attribute 'access (read_write, 1, 2)' here 42 | _FORTIFY_FN(fgets) char *fgets(char * _FORTIFY_POS0 __s, int __n, FILE *__f) | ^~~~~~~~~~~ ../bin/nsupdate/nsupdate.c:2405:14: note: 'cmdlinebuf' declared here 2405 | char cmdlinebuf[MAXCMD]; | ^~~~~~~~~~ This is a false positive, because fgets() only writes into the buffer; the fortify-headers wrapper annotates the buffer argument with 'access (read_write, ...)', which makes GCC treat passing an uninitialized buffer as a read of uninitialized memory. Initialize the 'cmdlinebuf' buffer anyway to avoid the build error. Assisted-by: Claude:claude-fable-5 (cherry picked from commit 62670aa1b7b69f493226a61e9220917afdbd3ae5) --- bin/nsupdate/nsupdate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c index a33693d512..9f7e57349d 100644 --- a/bin/nsupdate/nsupdate.c +++ b/bin/nsupdate/nsupdate.c @@ -2432,7 +2432,7 @@ do_next_command(char *cmdline) { static uint16_t get_next_command(void) { uint16_t result = STATUS_QUIT; - char cmdlinebuf[MAXCMD]; + char cmdlinebuf[MAXCMD] = { 0 }; char *cmdline = NULL, *ptr = NULL; if (interactive) {