Bug 10969 - duplocale crashes
Summary: duplocale crashes
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.8
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
Depends on:
Reported: 2009-11-17 00:58 UTC by Bruno Haible
Modified: 2014-07-01 05:21 UTC (History)
2 users (show)

See Also:
Host: x86_64-suse-linux
Target: x86_64-suse-linux
Build: x86_64-suse-linux
Last reconfirmed:
fweimer: security-

Test program (312 bytes, text/plain)
2009-11-17 00:59 UTC, Bruno Haible

Note You need to log in before you can comment on or make changes to this bug.
Description Bruno Haible 2009-11-17 00:58:18 UTC
The function call duplocale (LC_GLOBAL_LOCALE) crashes.
According to POSIX
and <http://www.opengroup.org/onlinepubs/9699919799/basedefs/locale.h.html>
it should instead return a duplicate copy of the global locale.

How to reproduce:
Compile and run the attached program.

1) POSIX says that LC_GLOBAL_LOCALE is "a special locale object descriptor",
   and the argument of duplocale has to be "a locale object" without further
2) The POSIX specification of newlocale says "The results are undefined if
   the base argument is the special locale object LC_GLOBAL_LOCALE" but similar
   wording is not present in the POSIX specification of duplocale.
3) The call works fine on MacOS X 10.5.
4) POSIX does not foresee any other way to create a copy of the global locale
   than through duplocale:
      newlocale (LC_ALL_MASK, "", LC_GLOBAL_LOCALE)
   has undefined behaviour, and
      newlocale (LC_ALL_MASK, nl_langinfo (_NL_LOCALE_NAME (LC_COLLATE)), NULL)
   uses API that is specific to glibc, not present in POSIX.
Comment 1 Bruno Haible 2009-11-17 00:59:31 UTC
Created attachment 4389 [details]
Test program
Comment 2 Ulrich Drepper 2009-11-17 17:38:27 UTC
Fixed in duplocale.

But it is completely irrelevant what macos does.  The specification is written
to follow the glibc implementation.