public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: MAHESH BODAPATI <bmahi496@linux.ibm.com>
To: Rajalakshmi Srinivasaraghavan <rajis@linux.vnet.ibm.com>,
	libc-alpha@sourceware.org
Cc: rajis@linux.ibm.com
Subject: Re: [PATCH] string: Fix tester build with fortify enable with gcc < 12
Date: Wed, 9 Aug 2023 20:20:20 +0530	[thread overview]
Message-ID: <0b4a2ec6-3790-c0e2-6b01-2aa3d1776b99@linux.ibm.com> (raw)
In-Reply-To: <16a5eb57-c89c-1d70-c4ef-683253bfae21@linux.vnet.ibm.com>


On 09/08/23 7:10 pm, Rajalakshmi Srinivasaraghavan wrote:
>
> On 8/9/23 7:03 AM, bmahi496@linux.ibm.com wrote:
>> From: Mahesh Bodapati <bmahi496@linux.ibm.com>
>>
>> When building with fortify enabled, GCC < 12 issues a warning on the
>> fortify strncat wrapper might overflow the destination buffer. However,
>> GCC does not provide a specific flag to disable the warning (the
>> failure is tied to -Werror). So to avoid disable all errors, only
>> enable the check for GCC 12 or newer.
>>
>> Checked on ppc64 and x86_64.
>> ---
>>   string/tester.c | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/string/tester.c b/string/tester.c
>> index f7d4bac5a8..cf3f5ae495 100644
>> --- a/string/tester.c
>> +++ b/string/tester.c
>> @@ -421,6 +421,12 @@ test_strncat (void)
>>     (void) strncat (one, "ij", (size_t)-1);    /* set sign bit in 
>> count */
>>     equal (one, "abcdghij", 13);
>>   +  /* When building with fortify enabled, GCC < 12 issues a warning 
>> on the
>> +     fortify strncat wrapper might overflow the destination buffer.  
>> However,
>> +     GCC does not provide a specific flag to disable the warning (the
>> +     failure is tied to -Werror). So to avoid disable all errors, only
>> +     enable the check for GCC 12 or newer.  */
>> +#if __GNUC_PREREQ (12, 0)
>
> Is it  possible to include a check for fortify enabled option ?

__USE_FORTIFY_LEVEL is 0 if fortify not enabled.

I will include it in the condition and share the updated patch.


>
>>     int ntest = 14;
>>     char buf1[80] __attribute__ ((aligned (16)));
>>     char buf2[32] __attribute__ ((aligned (16)));
>> @@ -464,6 +470,7 @@ test_strncat (void)
>>               }
>>           }
>>         }
>> +#endif
>>   }
>>     static void

  reply	other threads:[~2023-08-09 14:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-09 12:03 bmahi496
2023-08-09 13:40 ` Rajalakshmi Srinivasaraghavan
2023-08-09 14:50   ` MAHESH BODAPATI [this message]
2023-08-09 21:34 ` Joseph Myers
2023-08-10  7:09   ` MAHESH BODAPATI
2023-08-10 14:33     ` Joseph Myers
2023-08-11 13:34       ` MAHESH BODAPATI

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0b4a2ec6-3790-c0e2-6b01-2aa3d1776b99@linux.ibm.com \
    --to=bmahi496@linux.ibm.com \
    --cc=libc-alpha@sourceware.org \
    --cc=rajis@linux.ibm.com \
    --cc=rajis@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).