Closes Debian bug #757683, reported by Matthias Klose.
- Check for -fstack-protector-strong on supported platforms (since dpkg
1.17.11) (Debian bug #757885), reported by Markus Koschany.
- Consider lines with -O0 or -Og debug builds and disable checks for -O2
- (Debian bug #714628), reported by Matthias Klose.
+ (Debian bug #714628), reported by Matthias Klose. Also don't check for
+ fortification in those lines as it requires optimization (Debian bug
+ #757683), also reported by Matthias Klose.
Version 0.04
my @def_cppflags = ();
my @def_cppflags_fortify = (
'-D_FORTIFY_SOURCE=2', # must be first, see cppflags_fortify_broken()
- # If you add another flag fix hack below (search for "Hack to fix").
+ # If you add another flag fix hack below (search for "Hack to fix") and
+ # $def_cppflags_fortify[0].
);
my @def_cppflags_fortify_bad = (
# These flags may overwrite -D_FORTIFY_SOURCE=2.
# for a debug build.
if (any_flags_used($line, @def_cflags_debug)) {
remove_flags([\@cflags], \%flag_renames, $def_cflags[1]);
+ remove_flags([\@cppflags], \%flag_renames, $def_cppflags_fortify[0]);
}
# Check hardening flags.
gcc -g -O0 -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-d.c
gcc -Wl,-z,relro -o test test-a.o test-b.o test-c.o -ltest
+# -D_FORTIFY_SOURCE=2 requires -O2 to work, therfore ignore it for debug
+# lines.
+gcc -g -O0 -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security -c test-a.c
+gcc -g -O0 -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security -c test-b.c
+gcc -g -O0 -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security -c test-c.c
+gcc -g -O0 -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security -c test-d.c
+gcc -Wl,-z,relro -o test test-a.o test-b.o test-c.o -ltest
+
gcc -g -Og -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.c
gcc -g -Og -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-b.c
gcc -g -Og -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-c.c