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