* tests/test-duplocale.c (get_locale_dependent_values):
Don’t crash with absurdly long month names.
---
 ChangeLog              | 4 ++++
 tests/test-duplocale.c | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 9935941df..c1bf07eff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2017-09-25  Paul Eggert  <egg...@cs.ucla.edu>
 
+       duplocale-tests: fix unlikely crash
+       * tests/test-duplocale.c (get_locale_dependent_values):
+       Don’t crash with absurdly long month names.
+
        maint: fix overflow checking in nap.h
        * modules/chown-tests:
        * modules/fchownat-tests, modules/fdutimensat-tests:
diff --git a/tests/test-duplocale.c b/tests/test-duplocale.c
index 9b2c4cf1d..f48fedf6a 100644
--- a/tests/test-duplocale.c
+++ b/tests/test-duplocale.c
@@ -48,7 +48,8 @@ get_locale_dependent_values (struct locale_dependent_values 
*result)
   snprintf (result->numeric, sizeof (result->numeric),
             "%g", 3.5);
   /* result->numeric is usually "3,5" */
-  strcpy (result->time, nl_langinfo (MON_1));
+  strncpy (result->time, nl_langinfo (MON_1), sizeof result->time - 1);
+  result->time[sizeof result->time - 1] = '\0';
   /* result->time is usually "janvier" */
 }
 
-- 
2.13.5


Reply via email to