[PATCH] string: Fix tester build with fortify enable with gcc < 12
Rajalakshmi Srinivasaraghavan
rajis@linux.vnet.ibm.com
Wed Aug 9 13:40:22 GMT 2023
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 ?
> 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
More information about the Libc-alpha
mailing list