From: Zdenek Dohnal Date: Fri, 28 Apr 2023 08:00:27 +0000 (+0200) Subject: configure: Use _FORTIFY_SOURCE if not defined already X-Git-Tag: v2.4.3~28^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F642%2Fhead;p=thirdparty%2Fcups.git configure: Use _FORTIFY_SOURCE if not defined already If _FORTIFY_SOURCE is not defined in flags, use its level 3. Backported from libcups. --- diff --git a/config-scripts/cups-compiler.m4 b/config-scripts/cups-compiler.m4 index 266d909ed3..6a4f4ba87e 100644 --- a/config-scripts/cups-compiler.m4 +++ b/config-scripts/cups-compiler.m4 @@ -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... diff --git a/configure b/configure index 40d9e7a714..3af6165129 100755 --- 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