Bug 27996

Summary: setlocale should fail if the required gconv module is missing
Product: glibc Reporter: Florian Weimer <fweimer>
Component: localeAssignee: Siddhesh Poyarekar <siddhesh>
Status: NEW ---    
Severity: normal CC: carlos, fweimer, siddhesh, victor.stinner
Priority: P2 Flags: fweimer: security-
Version: unspecified   
Target Milestone: ---   
See Also: https://bugzilla.redhat.com/show_bug.cgi?id=1973663
Host: Target:
Build: Last reconfirmed:

Description Florian Weimer 2021-06-18 14:29:49 UTC
setlocale succeeds:

$ LC_ALL=lv_LV locale
LANG=
LC_CTYPE="lv_LV"
LC_NUMERIC="lv_LV"
LC_TIME="lv_LV"
LC_COLLATE="lv_LV"
LC_MONETARY="lv_LV"
LC_MESSAGES="lv_LV"
LC_PAPER="lv_LV"
LC_NAME="lv_LV"
LC_ADDRESS="lv_LV"
LC_TELEPHONE="lv_LV"
LC_MEASUREMENT="lv_LV"
LC_IDENTIFICATION="lv_LV"
LC_ALL=lv_LV

The locale uses a somewhat unusual charset:

# LC_ALL=lv_LV locale -k charmap
charmap="ISO-8859-13"

But the charset is not installed:

# iconv -f UTF-8 -t ISO-8859-13
iconv: failed to start conversion processing

So mbstowcs fails to work.

Pointed out by Victor Stinner here: https://bugzilla.redhat.com/show_bug.cgi?id=1973663#c11
Comment 1 Carlos O'Donell 2021-06-18 19:49:29 UTC
I agree setlocale should fail in this case.
Comment 2 Siddhesh Poyarekar 2021-06-30 08:57:47 UTC
Calling locale that way does not actually call setlocale().  I've got a test with a patch which does; sending soon.
Comment 3 Florian Weimer 2022-02-21 11:20:25 UTC
It may be prudent to turn ISO-8859-1 and ISO-8859-15 into internal converts, too, so that we don't encounter additional overhead due to early converter loading for these (somewhat common) character sets.