From e819a9ead9c9a1aef9cd12c74b8e115c6234ed5a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 25 Sep 2017 18:22:59 -0700 Subject: [PATCH] duplocale-tests: fix unlikely crash MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * 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 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" */ } -- 2.39.5