public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] string: Fix tester build with fortify enable with gcc 6
@ 2023-07-26 14:22 Adhemerval Zanella
  0 siblings, 0 replies; only message in thread
From: Adhemerval Zanella @ 2023-07-26 14:22 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=784ae968113011ce832b1808d4d42369f5d2e320

commit 784ae968113011ce832b1808d4d42369f5d2e320
Author: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Date:   Tue Jul 25 12:16:41 2023 -0300

    string: Fix tester build with fortify enable with gcc 6
    
    When building with fortify enabled, GCC 6 issues an warning the fortify
    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 7 or newer.
    
    Checked on i686-linux-gnu.
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>

Diff:
---
 string/tester.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/string/tester.c b/string/tester.c
index da42c72141..f7d4bac5a8 100644
--- a/string/tester.c
+++ b/string/tester.c
@@ -385,8 +385,17 @@ test_strncat (void)
 
   (void) strcpy (one, "gh");
   (void) strcpy (two, "ef");
+  /* When building with fortify enabled, GCC 6 issues an warning the fortify
+     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 7 or newer.  */
+#if __GNUC_PREREQ (7, 0)
   (void) strncat (one, two, 99);
   equal (one, "ghef", 5);			/* Basic test encore. */
+#else
+  equal (one, "gh", 2);
+#endif
   equal (two, "ef", 6);			/* Stomped on source? */
 
   (void) strcpy (one, "");

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-07-26 14:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-26 14:22 [glibc] string: Fix tester build with fortify enable with gcc 6 Adhemerval Zanella

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