]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
cdefs: Limit definition of fortification macros
authorSiddhesh Poyarekar <siddhesh@sourceware.org>
Thu, 2 Feb 2023 12:49:02 +0000 (07:49 -0500)
committerSiddhesh Poyarekar <siddhesh@sourceware.org>
Thu, 2 Feb 2023 14:29:33 +0000 (09:29 -0500)
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)

misc/sys/cdefs.h

index f525f67547f0c81902a591c8fc1f23b2cf38072e..294e633335998cad5dda2cf55f26fcba64d2b45a 100644 (file)
 # 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.  */
    ? __ ## 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.  */
    ? __ ## 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)))