From: Stefan Metzmacher Date: Mon, 30 Mar 2026 15:17:47 +0000 (+0200) Subject: wafsamba/samba_autoconf: add -Werror=array-bounds -Werror=stringop-overflow X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=d8b0244595fb219f02e8c4a7b87bfd8a0898ea0c;p=thirdparty%2Fsamba.git wafsamba/samba_autoconf: add -Werror=array-bounds -Werror=stringop-overflow Developer build should fail on such warnings... Signed-off-by: Stefan Metzmacher Reviewed-by: Andreas Schneider Autobuild-User(master): Stefan Metzmacher Autobuild-Date(master): Thu May 21 18:27:37 UTC 2026 on atb-devel-224 --- diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py index c21961e66db..d7f7baa334d 100644 --- a/buildtools/wafsamba/samba_autoconf.py +++ b/buildtools/wafsamba/samba_autoconf.py @@ -812,6 +812,10 @@ def SAMBA_CONFIG_H(conf, path=None): testflags=True) conf.ADD_CFLAGS('-Werror=old-style-definition -Wold-style-definition', testflags=True) + conf.ADD_CFLAGS('-Werror=array-bounds', + testflags=True) + conf.ADD_CFLAGS('-Werror=stringop-overflow', + testflags=True) conf.ADD_CFLAGS('-Wformat=2 -Wno-format-y2k', testflags=True) conf.ADD_CFLAGS('-Wno-format-zero-length', testflags=True) diff --git a/lib/util/ms_fnmatch.c b/lib/util/ms_fnmatch.c index 48454a8ecce..0d70f03a3ab 100644 --- a/lib/util/ms_fnmatch.c +++ b/lib/util/ms_fnmatch.c @@ -59,6 +59,15 @@ struct max_n { an optimisation only. The ldot pointer is NULL if the string does not contain a '.', otherwise it points at the last dot in 'n'. */ + +/* + * GCC's constant propagation creates a specialised version of this function + * where max_n is typed as struct max_n[0] (past-the-end pointer from the + * caller). The code is correct, max_n is never dereferenced in constprop + * variants that have no remaining wildcards. GCC warns conservatively here. + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Warray-bounds" static int ms_fnmatch_core(const char *p, const char *n, struct max_n *max_n, const char *ldot, bool is_case_sensitive) @@ -175,6 +184,7 @@ static int ms_fnmatch_core(const char *p, const char *n, return -1; } +#pragma GCC diagnostic pop int ms_fnmatch_protocol(const char *pattern, const char *string, int protocol, bool is_case_sensitive)