This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/5486] New: nl_langinfo() returns invalid pointer instead of expected empty string


man nl_langinfo says:
"If item is not valid, a pointer to an empty string is returned."
But nl_langinfo(0x11) returns invalid pointer.

See the code below:
---
#include <stdio.h>
#include <langinfo.h>
int main() {
        char *val;
        val = nl_langinfo(0x11);
        printf("%s\n", val);
        return 0;
}
---

GDB:
---
Breakpoint 1, main () at test.c:7
7               val = nl_langinfo(0x11);
(gdb) n
8               printf("%s\n", val);
(gdb) p val
$1 = 0x47 <Address 0x47 out of bounds>

valgrind:
---
==26754== Invalid read of size 1
==26754==    at 0x4C23D92: strlen (mc_replace_strmem.c:242)
==26754==    by 0x4E88E9A: puts (in /lib64/libc-2.6.1.so)
==26754==    by 0x40058A: main (in /tmp/nl_lang)
==26754==  Address 0x47 is not stack'd, malloc'd or (recently) free'd
==26754==
==26754== Process terminating with default action of signal 11 (SIGSEGV)
==26754==  Access not within mapped region at address 0x47
==26754==    at 0x4C23D92: strlen (mc_replace_strmem.c:242)
==26754==    by 0x4E88E9A: puts (in /lib64/libc-2.6.1.so)
==26754==    by 0x40058A: main (in /tmp/nl_lang)

The problem is reproducible with glibc 2.6.1 (openSUSE 10.3 x86_64) and 2.5 
(openSUSE 10.2 x86_64 and x86).

-- 
           Summary: nl_langinfo() returns invalid pointer instead of
                    expected empty string
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: bugs at daylessday dot org
                CC: glibc-bugs at sources dot redhat dot com
  GCC host triplet: x86_64-unknown-linux-gnu


http://sourceware.org/bugzilla/show_bug.cgi?id=5486

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]