|
|
1feee8 |
commit c5c792092b57687ae3ebecbe8645fa71ddb19f8c
|
|
|
1feee8 |
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
|
|
1feee8 |
Date: Thu Feb 2 07:49:02 2023 -0500
|
|
|
1feee8 |
|
|
|
1feee8 |
cdefs: Limit definition of fortification macros
|
|
|
1feee8 |
|
|
|
1feee8 |
Define the __glibc_fortify and other macros only when __FORTIFY_LEVEL >
|
|
|
1feee8 |
0. This has the effect of not defining these macros on older C90
|
|
|
1feee8 |
compilers that do not have support for variable length argument lists.
|
|
|
1feee8 |
|
|
|
1feee8 |
Also trim off the trailing backslashes from the definition of
|
|
|
1feee8 |
__glibc_fortify and __glibc_fortify_n macros.
|
|
|
1feee8 |
|
|
|
1feee8 |
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
|
|
1feee8 |
Reviewed-by: Florian Weimer <fweimer@redhat.com>
|
|
|
1feee8 |
(cherry picked from commit 2337e04e21ba6040926ec871e403533f77043c40)
|
|
|
1feee8 |
|
|
|
1feee8 |
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
|
|
|
1feee8 |
index b166f3d209fe361f..92dbd3e1fc68dae7 100644
|
|
|
1feee8 |
--- a/misc/sys/cdefs.h
|
|
|
1feee8 |
+++ b/misc/sys/cdefs.h
|
|
|
1feee8 |
@@ -151,6 +151,7 @@
|
|
|
1feee8 |
# define __glibc_objsize(__o) __bos (__o)
|
|
|
1feee8 |
#endif
|
|
|
1feee8 |
|
|
|
1feee8 |
+#if __USE_FORTIFY_LEVEL > 0
|
|
|
1feee8 |
/* Compile time conditions to choose between the regular, _chk and _chk_warn
|
|
|
1feee8 |
variants. These conditions should get evaluated to constant and optimized
|
|
|
1feee8 |
away. */
|
|
|
1feee8 |
@@ -186,7 +187,7 @@
|
|
|
1feee8 |
? __ ## f ## _alias (__VA_ARGS__) \
|
|
|
1feee8 |
: (__glibc_unsafe_len (__l, __s, __osz) \
|
|
|
1feee8 |
? __ ## f ## _chk_warn (__VA_ARGS__, __osz) \
|
|
|
1feee8 |
- : __ ## f ## _chk (__VA_ARGS__, __osz))) \
|
|
|
1feee8 |
+ : __ ## f ## _chk (__VA_ARGS__, __osz)))
|
|
|
1feee8 |
|
|
|
1feee8 |
/* Fortify function f, where object size argument passed to f is the number of
|
|
|
1feee8 |
elements and not total size. */
|
|
|
1feee8 |
@@ -196,7 +197,8 @@
|
|
|
1feee8 |
? __ ## f ## _alias (__VA_ARGS__) \
|
|
|
1feee8 |
: (__glibc_unsafe_len (__l, __s, __osz) \
|
|
|
1feee8 |
? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s)) \
|
|
|
1feee8 |
- : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s)))) \
|
|
|
1feee8 |
+ : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s))))
|
|
|
1feee8 |
+#endif
|
|
|
1feee8 |
|
|
|
1feee8 |
#if __GNUC_PREREQ (4,3)
|
|
|
1feee8 |
# define __warnattr(msg) __attribute__((__warning__ (msg)))
|