]> sourceware.org Git - newlib-cygwin.git/commit
newlocale: fix crash when trying to write to __C_locale
authorCorinna Vinschen <corinna@vinschen.de>
Thu, 11 Aug 2022 17:27:48 +0000 (19:27 +0200)
committerCorinna Vinschen <corinna@vinschen.de>
Fri, 12 Aug 2022 10:29:26 +0000 (12:29 +0200)
commit85be74f2951968be7fe1979014d6246171ebd123
tree41de9537aa7ddb548f8ba9a982f93cca6a49cc9c
parentbf1d972d5c397125d879d6334c84012f166af9eb
newlocale: fix crash when trying to write to __C_locale

This simple testcase:

  locale_t st = newlocale(LC_ALL_MASK, "C", (locale_t)0);
  locale_t st2 = newlocale(LC_CTYPE_MASK, "en_US.UTF-8", st);

is sufficient to reproduce a crash in _newlocale_r.  After the first call
to newlocale, `st' points to __C_locale, which is const.  When using `st'
as locale base in the second call, _newlocale_r tries to set pointers
inside base to NULL.  This is bad if base is __C_locale, obviously.

Add a test to avoid trying to overwrite pointer values inside base if
base is __C_locale.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
newlib/libc/locale/newlocale.c
winsup/cygwin/release/3.3.6
This page took 0.030547 seconds and 5 git commands to generate.