]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
configure: Use _FORTIFY_SOURCE if not defined already 642/head
authorZdenek Dohnal <zdohnal@redhat.com>
Fri, 28 Apr 2023 08:00:27 +0000 (10:00 +0200)
committerZdenek Dohnal <zdohnal@redhat.com>
Fri, 28 Apr 2023 08:03:57 +0000 (10:03 +0200)
If _FORTIFY_SOURCE is not defined in flags, use its level 3.

Backported from libcups.

config-scripts/cups-compiler.m4
configure

index 266d909ed32740ab714a376f874c8b797fc542cf..6a4f4ba87e8791a6987c7a0056eb53583c16cfc6 100644 (file)
@@ -105,11 +105,13 @@ AS_IF([test -n "$GCC"], [
     AS_IF([test x$enable_sanitizer = xyes], [
        # Use -fsanitize=address with debugging...
        OPTIM="$OPTIM -g -fsanitize=address"
+    ], [echo "$CXXFLAGS $CFLAGS" | grep -q _FORTIFY_SOURCE], [
+        # Don't add _FORTIFY_SOURCE if it is already there
     ], [
        # Otherwise use the Fortify enhancements to catch any unbounded
        # string operations...
-       CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
-       CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=2"
+       CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=3"
+       CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=3"
     ])
 
     # Default optimization options...
index 40d9e7a714233d1fa42db8fbf17ef55b92f7cb27..3af6165129489d53f2c828837d84c69a46b2acd5 100755 (executable)
--- a/configure
+++ b/configure
@@ -8098,12 +8098,17 @@ then :
        # Use -fsanitize=address with debugging...
        OPTIM="$OPTIM -g -fsanitize=address"
 
+elif echo "$CXXFLAGS $CFLAGS" | grep -q _FORTIFY_SOURCE
+then :
+
+        # Don't add _FORTIFY_SOURCE if it is already there
+
 else $as_nop
 
        # Otherwise use the Fortify enhancements to catch any unbounded
        # string operations...
-       CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
-       CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=2"
+       CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=3"
+       CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=3"
 
 fi