[PATCH] iconvconfig: Fix multiple issues
Florian Weimer
fweimer@redhat.com
Fri Jun 25 07:26:46 GMT 2021
* Siddhesh Poyarekar via Libc-alpha:
> It was noticed on big-endian systems that msgfmt would fail with the
> following error:
>
> msgfmt: gconv_builtin.c:70: __gconv_get_builtin_trans: Assertion `cnt < sizeof (map) / sizeof (map[0])' failed.
> Aborted (core dumped)
>
> This is only seen on installed systems because it was due to a
> corrupted gconv-modules.cache. iconvconfig had the following issues
> (it was specifically freeing fulldir that caused this issue, but other
> cleanups are also needed) that this patch fixes.
>
> - Add prefix only if dir starts with '/'
> - Use stpcpy instead of mempcpy so that the directory string is NULL
> terminated
>
> - Do not free fulldir because it is used later while writing out the
> gconv-modules.cache file.
I suggest to use asprintf. This code is hardly performance critical,
and asprintf avoids such bugs.
I expect that static analysis tools can detect the missing free calls,
so I think we should still free those allocations.
Thanks,
Florian
More information about the Libc-alpha
mailing list