summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdhemerval Zanella Netto <adhemerval.zanella@linaro.org>2023-07-25 12:16:41 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2023-07-26 10:45:49 -0300
commit784ae968113011ce832b1808d4d42369f5d2e320 (patch)
tree71eeb7adf838ac6c472d955d2e63e6066ce66780
parentdbc4b032dc5c4ef0c46e9de23c46b1698bad4412 (diff)
downloadglibc-784ae968113011ce832b1808d4d42369f5d2e320.tar.gz
glibc-784ae968113011ce832b1808d4d42369f5d2e320.tar.xz
glibc-784ae968113011ce832b1808d4d42369f5d2e320.zip
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>
-rw-r--r--string/tester.c9
1 files changed, 9 insertions, 0 deletions
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, "");