Bug 10968 - _NL_LOCALE_NAME macro does not work
Summary: _NL_LOCALE_NAME macro does not work
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:37 UTC by Bruno Haible
Modified: 2014-07-01 05:22 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 (337 bytes, text/plain)
2009-11-17 00:38 UTC, Bruno Haible
proposed fix (282 bytes, patch)
2009-11-17 00:47 UTC, Bruno Haible
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bruno Haible 2009-11-17 00:37:43 UTC
In <http://sourceware.org/ml/libc-alpha/2005-03/msg00179.html> a macro
_NL_LOCALE_NAME was introduced, whose purpose it is to access the name
of the current locale. But it does not work: with it, the nl_langinfo
function always returns the empty string.

How to reproduce: Compile and run the attached program bug1.c.

The reason, found by Ludovic Courtès, is that in the macroexpansion of
_NL_ITEM (category, -1)  =>  (((category) << 16) | (-1))
the bits 31..16 of the number -1 overwrite the bits of the category.
The suggested fix therefore is to change the _NL_LOCALE_NAME macro
as indicated in bug1.c.
Comment 1 Bruno Haible 2009-11-17 00:38:31 UTC
Created attachment 4387 [details]
Test program
Comment 2 Bruno Haible 2009-11-17 00:47:08 UTC
Created attachment 4388 [details]
proposed fix
Comment 3 Ulrich Drepper 2009-11-17 17:38:40 UTC
Fixed in git.