Bug 10968

Summary: _NL_LOCALE_NAME macro does not work
Product: glibc Reporter: Bruno Haible <bruno>
Component: libcAssignee: Ulrich Drepper <drepper.fsp>
Severity: normal CC: glibc-bugs, ludo
Priority: P2 Flags: fweimer: security-
Version: 2.8   
Target Milestone: ---   
Host: x86_64-suse-linux Target: x86_64-suse-linux
Build: x86_64-suse-linux Last reconfirmed:
Attachments: Test program
proposed fix

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.