[PATCH] setlocale: Fail if iconv module for charset is not present [BZ #27996]
Siddhesh Poyarekar
siddhesh@sourceware.org
Mon Jul 19 08:34:58 GMT 2021
On 7/17/21 1:58 AM, Carlos O'Donell wrote:
>> +
>> + struct gconv_module *root = __gconv_modules_db;
>> +
>> + while (root != NULL)
>> + {
>> + int cmpres;
>> +
>> + cmpres = strcmp (name, root->from_string);
>
> I think this is incomplete.
>
> (a) We must have a converter that goes from name->INTERNAL.
> (b) We must have a converter that goes from INTERNAL->name.
>
> You are only checking for (a) here, which means we can read
> input of the charset, but we can't write it out via printf
> and I don't think that would match user expectations.
Hmm, I had assumed that the presence of name->INTERNAL implies the
presence of INTERNAL->name. If we had to be properly general purpose
then the check ought to confirm that we can actually find a
transformation from name->INTERNAL and back:
===========
if (__gconv_find_transform ("INTERNAL", name, &steps, &nsteps,
0) != __GCONV_OK)
return false;
__gconv_close_transform (steps, nsteps);
if (__gconv_find_transform (name, "INTERNAL", &steps, &nsteps,
0) != __GCONV_OK)
return false;
__gconv_close_transform (steps, nsteps);
return true;
===========
Does that sound right?
Siddhesh
More information about the Libc-alpha
mailing list