From f6138a72338559c3c2d3535b8a969f9d4124c021 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Mon, 16 Nov 2020 14:26:16 -0600 Subject: locale: Fix two correctness issues * Count size of list correctly * Don't make __names const; it isn't. --- libgcompat/locale.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libgcompat/locale.c b/libgcompat/locale.c index a7ac2c0..538ece7 100644 --- a/libgcompat/locale.c +++ b/libgcompat/locale.c @@ -15,7 +15,7 @@ struct glibc_locale { const int *__ctype_tolower; const int *__ctype_toupper; - const char *__names[13]; + char *__names[13]; }; const unsigned short **__ctype_b_loc(void); @@ -23,9 +23,10 @@ const int32_t **__ctype_tolower_loc(void); const int32_t **__ctype_toupper_loc(void); const char *__gcompat_valid_locales[] = {"C", "POSIX"}; +#define valid_locale_count sizeof __gcompat_valid_locales / sizeof *__gcompat_valid_locales bool _is_valid_locale(const char *candidate) { - for(int i = 0; i < sizeof __gcompat_valid_locales; i++) { + for(size_t i = 0; i < valid_locale_count; i++) { if(strcmp(candidate, __gcompat_valid_locales[i]) == 0) return true; } return false; -- cgit v1.2.3-60-g2f50