[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/6] duplocale-tests: fix unlikely crash
From: |
Paul Eggert |
Subject: |
[PATCH 5/6] duplocale-tests: fix unlikely crash |
Date: |
Mon, 25 Sep 2017 18:29:12 -0700 |
* 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 <address@hidden>
+ 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
- [PATCH 1/6] parse-datetime, posixtm: avoid uninit access, Paul Eggert, 2017/09/25
- [PATCH 2/6] parse-datetime: fix dependency, Paul Eggert, 2017/09/25
- [PATCH 3/6] sys_types: update URL, Paul Eggert, 2017/09/25
- [PATCH 4/6] maint: fix overflow checking in nap.h, Paul Eggert, 2017/09/25
- [PATCH 5/6] duplocale-tests: fix unlikely crash,
Paul Eggert <=
- new module 'strlcpy', Bruno Haible, 2017/09/27
- Re: new module 'strlcpy', Paul Eggert, 2017/09/27
- Re: new module 'strlcpy', Bruno Haible, 2017/09/27
- Re: new module 'strlcpy', Bruno Haible, 2017/09/27
- Re: new module 'strlcpy', Jim Meyering, 2017/09/27
- Re: new module 'strlcpy', Bruno Haible, 2017/09/28
- Re: new module 'strlcpy', Paul Eggert, 2017/09/28
- Re: new module 'strlcpy', Paul Eggert, 2017/09/27
- Re: new module 'strlcpy', Dmitry Selyutin, 2017/09/28
- Re: new module 'strlcpy', Tim Rühsen, 2017/09/28