From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2206) id 882ED3858C60; Thu, 2 Feb 2023 14:29:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 882ED3858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675348196; bh=nMuiuhnrZ0hBZNnjgLAHShFWU71K8uXsimqj2XBCj90=; h=From:To:Subject:Date:From; b=ZspPWTeUYf1s/bXlPu1+PC7nvpFXG+gDrdb3EHpSkte/deuKFAVwxgrLN4nq5eBdI oRYPi2iv7+Q039eweZ7MiDEAs/9jRLFHSre4Pr3m1FGOsuAw2qKyTVsi7xLGwdyclT CAuB2amSWRRlddB87cXVwlkwlNbUcqQ3eL0AkkcE= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Siddhesh Poyarekar To: glibc-cvs@sourceware.org Subject: [glibc/release/2.36/master] cdefs: Limit definition of fortification macros X-Act-Checkin: glibc X-Git-Author: Siddhesh Poyarekar X-Git-Refname: refs/heads/release/2.36/master X-Git-Oldrev: 93967a2a7bbdcedb73e0b246713580c7c84d001e X-Git-Newrev: 56e00c585420af63fc4df9e28ff9e12bb2a3274f Message-Id: <20230202142956.882ED3858C60@sourceware.org> Date: Thu, 2 Feb 2023 14:29:56 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=56e00c585420af63fc4df9e28ff9e12bb2a3274f commit 56e00c585420af63fc4df9e28ff9e12bb2a3274f Author: Siddhesh Poyarekar Date: Thu Feb 2 07:49:02 2023 -0500 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 Reviewed-by: Florian Weimer (cherry picked from commit 2337e04e21ba6040926ec871e403533f77043c40) Diff: --- misc/sys/cdefs.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h index f525f67547..294e633335 100644 --- a/misc/sys/cdefs.h +++ b/misc/sys/cdefs.h @@ -152,6 +152,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. */ @@ -187,7 +188,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. */ @@ -197,7 +198,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)))