mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-27 03:33:33 +08:00
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>
This commit is contained in:
parent
dbc4b032dc
commit
784ae96811
@ -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, "");
|
||||
|
Loading…
Reference in New Issue
Block a user