From: Paul Eggert Date: Tue, 26 Sep 2017 01:22:59 +0000 (-0700) Subject: duplocale-tests: fix unlikely crash X-Git-Tag: v1.0~5901 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=e819a9ead9c9a1aef9cd12c74b8e115c6234ed5a;p=gnulib.git duplocale-tests: fix unlikely crash * tests/test-duplocale.c (get_locale_dependent_values): Don’t crash with absurdly long month names. --- diff --git a/ChangeLog b/ChangeLog index 9935941df2..c1bf07eff0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2017-09-25 Paul Eggert + 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 9b2c4cf1d0..f48fedf6ad 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" */ }