summaryrefslogtreecommitdiff
path: root/sys-apps/kbd/files/kbd-2.6.3-no-redefine-fortify-source.patch
blob: 2edd547d1ed2c7eb62aa6a48c478db4bcdb396fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
https://github.com/legionus/kbd/pull/103

From 3392e2038dee97361d7438512653736d72a02109 Mon Sep 17 00:00:00 2001
From: Sam James <sam@gentoo.org>
Date: Wed, 4 Oct 2023 14:47:33 +0100
Subject: [PATCH] Use `AX_ADD_FORTIFY_SOURCE` to avoid redefining
 `_FORTIFY_SOURCE`

Some distributions are now setting -D_FORTIFY_SOURCE=3 by default in their
toolchains rather than _F_S=2. By forcing _F_S=2, this causes both a warning
and a downgrade in the effective protection.

Use the autoconf-archive macro for this purpose (AX_ADD_FORTIFY_SOURCE)
to add the fortification at the highest supported level if the compiler doesn't
already default to it.

Bug: https://bugs.gentoo.org/892834
Signed-off-by: Sam James <sam@gentoo.org>
---
 configure.ac                |   5 +-
 m4/ax_add_fortify_source.m4 | 119 ++++++++++++++++++++++++++++++++++++
 2 files changed, 122 insertions(+), 2 deletions(-)
 create mode 100644 m4/ax_add_fortify_source.m4

diff --git a/configure.ac b/configure.ac
index 66023ff8..7fdbe7d6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -63,13 +63,14 @@ strspn strstr strtol strtoul setpgrp malloc realloc])
 
 AC_SEARCH_LIBS([timer_create], [rt])
 
+AX_ADD_FORTIFY_SOURCE
+
 # Optimization level
 CC_O_LEVEL="-O2"
-FORTIFY_SOURCE="-D_FORTIFY_SOURCE=2"
 
 if test "$enable_code_coverage" = yes; then
 	CC_O_LEVEL="-O0"
-	FORTIFY_SOURCE=
+	FORTIFY_SOURCE="-U_FORTIFY_SOURCE"
 fi
 
 case "$GCC,$ac_cv_prog_cc_g" in