]> Savannah Git Hosting - gnulib.git/commitdiff
duplocale-tests: fix unlikely crash
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 26 Sep 2017 01:22:59 +0000 (18:22 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 26 Sep 2017 01:28:31 +0000 (18:28 -0700)
* tests/test-duplocale.c (get_locale_dependent_values):
Don’t crash with absurdly long month names.

ChangeLog
tests/test-duplocale.c

index 9935941df23ba4121d88f6186a8fec9422c9a5db..c1bf07eff00c6185ab70b04324bbfa7e11b5dc24 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2017-09-25  Paul Eggert  <eggert@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:
index 9b2c4cf1d0db4cb71af541bb031d712b260ef35f..f48fedf6ad9653ab5ec8c3a463546c5314330b54 100644 (file)
@@ -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" */
 }