|
|
Message-ID: <20261005163908.GK23438@brightrain.aerifal.cx>
Date: Mon, 5 Oct 2026 12:39:08 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: [PATCH v2] musl locale overhaul series, take 2
On Fri, Oct 02, 2026 at 01:38:00AM -0400, Rich Felker wrote:
> From c45dbe1d43d5a5aab85f529902f3f57d8149fe7a Mon Sep 17 00:00:00 2001
> From: Rich Felker <dalias@...ifal.cx>
> Date: Fri, 18 Sep 2026 11:32:47 -0400
> Subject: [PATCH 19/23] implement non-stub localeconv
>
> because struct lconv mixes data from LC_NUMERIC and LC_MONETARY, it
> cannot be a constant structure held with the loaded locale. it has to
> be expanded from the relevant properties in the different categories
> to the locale object referenced by locale_t or the global locale.
>
> setlocale and newlocale are modified to expand the actual locale data
> into the target locale object. the mutable global locale structure is
> pre-initialized with the C locale values, so that no code is needed to
> prep it, and the static __c_locale and __c_dot_utf8_locale objects
> which exist to make newlocale failure-free for these locales also hold
> copies of this data.
> ---
> src/internal/locale_impl.h | 2 ++
> src/locale/localeconv.c | 51 +++++++++++++++++++++++++++++++++++++-
> src/locale/newlocale.c | 28 ++++++++++++++++-----
> src/locale/setlocale.c | 9 +++++++
> 4 files changed, 83 insertions(+), 7 deletions(-)
>
> [...]
>
> diff --git a/src/locale/setlocale.c b/src/locale/setlocale.c
> index a14b0ea6..e7f3afd7 100644
> --- a/src/locale/setlocale.c
> +++ b/src/locale/setlocale.c
> @@ -7,6 +7,12 @@
>
> static char buf[LC_ALL*(LOCALE_NAME_MAX+1)];
>
> +static void dummy_lconv_expand(locale_t loc)
> +{
> +}
> +
> +weak_alias(dummy_lconv_expand, __lconv_expand);
> +
> char *setlocale(int cat, const char *name)
> {
> const struct __locale_map *lm;
> @@ -40,6 +46,7 @@ char *setlocale(int cat, const char *name)
> }
> tmp_locale.cat[i] = lm;
> }
> + __lconv_expand(&tmp_locale);
> __global_locale = tmp_locale;
This line causes access to a potentially uninitialized pointer in
tmp_locale; it was missed because my testing had fresh zero-filled
stack.
Attached patch fixes it. I'll amend this in when merging.
Rich
View attachment "lconv_fixup.diff" of type "text/plain" (353 bytes)
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.