]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
wafsamba: Add -D_FORTIFY_SOURCE=3 when stack protector is enabled
authorAndreas Schneider <asn@samba.org>
Tue, 24 Mar 2026 14:00:21 +0000 (15:00 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 27 Mar 2026 08:33:09 +0000 (08:33 +0000)
The capability check in SAMBA_CONFIG_H() already tests that the compiler
accepts both -Wp,-D_FORTIFY_SOURCE and the stack protector flag
together, but only the stack protector flag was added to EXTRA_CFLAGS on
success.

The glibc normally silently downgrades to the supported level if the on
specified is not supported.

Note that -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 only sets it if not
already defined.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=16040

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Mar 27 08:33:09 UTC 2026 on atb-devel-224

buildtools/wafsamba/samba_autoconf.py
script/autobuild.py

index b777391a03809bb7d7691965739dabc0abfe31e3..979d5a3972f8f81c6f451370b91c06018e9fdfea 100644 (file)
@@ -733,11 +733,16 @@ def SAMBA_CONFIG_H(conf, path=None):
                                     }
                                     ''',
                                     execute=0,
-                                    cflags=[ '-Werror', '-Wp,-D_FORTIFY_SOURCE=2', stack_protect_flag],
+                                    cflags=[
+                                        '-Werror',
+                                        '-Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3',
+                                        stack_protect_flag
+                                    ],
                                     mandatory=False,
                                     msg='Checking if compiler accepts %s' % (stack_protect_flag))
         if flag_supported:
             conf.ADD_CFLAGS('%s' % (stack_protect_flag))
+            conf.ADD_CFLAGS('-Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3')
             break
 
     flag_supported = conf.check(fragment='''
index b2d3bd0bde4e2227a29bb2e79ea782c9aced5842..be8c4529b56f6fcd25101ae78df39d66d9209a8f 100755 (executable)
@@ -210,13 +210,7 @@ try:
 except ImportError:
     pass
 
-# on ubuntu gcc implies _FORTIFY_SOURCE
-# before 24.04 it was _FORTIFY_SOURCE=2
-# and 24.04 has _FORTIFY_SOURCE=3
-# so we do not specify it explicitly.
 samba_o3_cflags = "-O3"
-if not is_ubuntu:
-    samba_o3_cflags += " -Wp,-D_FORTIFY_SOURCE=2"
 
 def format_option(name, value=None):
     """Format option as str list."""