This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: search locale archive again after alias expansion
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: Roland McGrath <roland at hack dot frob dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Thu, 19 Sep 2013 00:49:28 -0300
- Subject: Re: search locale archive again after alias expansion
- Authentication-results: sourceware.org; auth=none
- References: <orr4dao5h6 dot fsf at livre dot home> <20130918220004 dot B23492C09F at topped-with-meat dot com>
On Sep 18, 2013, Roland McGrath <roland@hack.frob.com> wrote:
> user-visible change needs a bug filed
Thanks, done. Here's the patch, updated to mention it.
BZ #15969: search locale archive again after alias expansion
If a locale alias is defined in locale.alias but not in an archive,
and the referenced locale is only present in the archive, setlocale
will fail if given the alias name. This is unintuitive. This patch
fixes it, arranging for the locale archive to be searched again after
alias expansion.
for ChangeLog
[BZ #15969]
* locale/findlocale.c (_nl_find_locale): Retry archive search
after alias expansion.
* NEWS: Updated.
---
NEWS | 2 +-
locale/findlocale.c | 19 +++++++++++++++----
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/NEWS b/NEWS
index af58b752..6325975 100644
--- a/NEWS
+++ b/NEWS
@@ -11,7 +11,7 @@ Version 2.19
14155, 14699, 15427, 15522, 15531, 15532, 15736, 15748, 15749, 15797,
15844, 15849, 15855, 15856, 15857, 15867, 15886, 15887, 15890, 15892,
- 15893, 15895, 15897, 15905, 15909, 15921, 15939.
+ 15893, 15895, 15897, 15905, 15909, 15921, 15939, 15969.
* CVE-2013-4237 The readdir_r function could write more than NAME_MAX bytes
to the d_name member of struct dirent, or omit the terminating NUL
diff --git a/locale/findlocale.c b/locale/findlocale.c
index 3c04aa8..845e260 100644
--- a/locale/findlocale.c
+++ b/locale/findlocale.c
@@ -108,15 +108,26 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len,
if (__builtin_expect (data != NULL, 1))
return data;
+ /* Nothing in the archive with the given name. Expanding it as
+ an alias and retry. */
+ loc_name = (char *) _nl_expand_alias (*name);
+ if (loc_name != NULL)
+ {
+ data = _nl_load_locale_from_archive (category, &loc_name);
+ if (__builtin_expect (data != NULL, 1))
+ return data;
+ }
+
/* Nothing in the archive. Set the default path to search below. */
locale_path = _nl_default_locale_path;
locale_path_len = sizeof _nl_default_locale_path;
}
+ else
+ /* We really have to load some data. First see whether the name is
+ an alias. Please note that this makes it impossible to have "C"
+ or "POSIX" as aliases. */
+ loc_name = (char *) _nl_expand_alias (*name);
- /* We really have to load some data. First see whether the name is
- an alias. Please note that this makes it impossible to have "C"
- or "POSIX" as aliases. */
- loc_name = (char *) _nl_expand_alias (*name);
if (loc_name == NULL)
/* It is no alias. */
loc_name = (char *) *name;
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist Red Hat Brazil Compiler Engineer