Summary: | newlocale doesn't always set errno upon failure return | ||
---|---|---|---|
Product: | glibc | Reporter: | law |
Component: | locale | Assignee: | Carlos O'Donell <carlos> |
Status: | ASSIGNED --- | ||
Severity: | normal | CC: | carlos, kristian.spangsege, libc-locales |
Priority: | P2 | Flags: | fweimer:
security-
|
Version: | 2.15 | ||
Target Milestone: | --- | ||
See Also: |
https://bugzilla.redhat.com/show_bug.cgi?id=827510 https://bugzilla.redhat.com/show_bug.cgi?id=2252433 https://bugzilla.redhat.com/show_bug.cgi?id=832516 |
||
Host: | Target: | ||
Build: | Last reconfirmed: | ||
Attachments: |
Potential fix
0001-locale-Handle-loading-a-missing-locale-twice-Bug-142.patch |
This bug is still present in GLIBC 2.31 The fix is incomplete since when multiple paths are part of the lookup the test case still fails. Created attachment 15233 [details]
0001-locale-Handle-loading-a-missing-locale-twice-Bug-142.patch
Fixes both locations that need fixing.
Adds a test case.
|
Created attachment 6449 [details] Potential fix newlocale() neglects to set errno to an appropriate value when failing, if it has already been asked about the same incorrect locale name. #include <stdio.h> #include <errno.h> #include <locale.h> int main(int argc, char **argv) { locale_t loc; setlocale(LC_ALL, "C"); errno = 0; loc = newlocale(LC_COLLATE_MASK | LC_CTYPE_MASK, "nb_no.utf8", 0); printf("result = %p errno = %d\n", loc, errno); errno = 0; loc = newlocale(LC_COLLATE_MASK | LC_CTYPE_MASK, "nb_no.utf8", 0); printf("result = %p errno = %d\n", loc, errno); return 0; } Actual results: result = (nil) errno = 2 result = (nil) errno = 0 Expected results: result = (nil) errno = 2 result = (nil) errno = 2 (or at least something other than 0)