Bug 27996 - setlocale should fail if the required gconv module is missing
Summary: setlocale should fail if the required gconv module is missing
Status: NEW
Alias: None
Product: glibc
Classification: Unclassified
Component: locale (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Siddhesh Poyarekar
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-18 14:29 UTC by Florian Weimer
Modified: 2022-02-21 11:20 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.