This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC][PATCH v9 1/6] Correct the size of _nl_value_type_LC_... arrays.


There were several problems with checking the array size in the past,
for example BZ#356, caused by incorrectly assuming that every locale
token represents one element.  In fact, if a token represented
a subarray, for example an array of month names or characters category
and it appeared at the end of the array the compiler assumed that
the array ends just after the first element of the subarray.
Workarounds used in the past was to skip some categories while testing,
for example LC_CTYPE.  Now when we are about to add alternative month
names to LC_TIME (BZ#10871) this will fail again.

	* locale/loadlocale.c: Correct size of
	_nl_value_type_LC_<category> arrays.
---
 ChangeLog           | 5 +++++
 locale/loadlocale.c | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 25b05f2..3b8e6c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-09-19  Rafal Luzynski  <digitalfreak@lingonborough.com>
+
+	* locale/loadlocale.c: Correct size of
+	_nl_value_type_LC_<category> arrays.
+
 2017-09-19  Rajalakshmi Srinivasaraghavan  <raji@linux.vnet.ibm.com>
 
 	* sysdeps/powerpc/powerpc64/power8/memset.S: Avoid misaligned stores.
diff --git a/locale/loadlocale.c b/locale/loadlocale.c
index 2bdb39b..cdc3dd4 100644
--- a/locale/loadlocale.c
+++ b/locale/loadlocale.c
@@ -45,7 +45,8 @@ static const size_t _nl_category_num_items[] =
 #define NO_PAREN(arg, rest...) arg, ##rest
 
 #define DEFINE_CATEGORY(category, category_name, items, a) \
-static const enum value_type _nl_value_type_##category[] = { NO_PAREN items };
+static const enum value_type _nl_value_type_##category     \
+  [_NL_ITEM_INDEX (_NL_NUM_##category)] = { NO_PAREN items };
 #define DEFINE_ELEMENT(element, element_name, optstd, type, rest...) \
   [_NL_ITEM_INDEX (element)] = type,
 #include "categories.def"
-- 
2.7.5


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]