public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] string: Fix tester build with fortify enable with gcc < 12
@ 2023-08-09 12:03 bmahi496
  2023-08-09 13:40 ` Rajalakshmi Srinivasaraghavan
  2023-08-09 21:34 ` Joseph Myers
  0 siblings, 2 replies; 7+ messages in thread
From: bmahi496 @ 2023-08-09 12:03 UTC (permalink / raw)
  To: libc-alpha; +Cc: rajis, Mahesh Bodapati

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)
   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
-- 
2.31.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-08-11 13:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-09 12:03 [PATCH] string: Fix tester build with fortify enable with gcc < 12 bmahi496
2023-08-09 13:40 ` Rajalakshmi Srinivasaraghavan
2023-08-09 14:50   ` MAHESH BODAPATI
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

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).