[PATCH 07/11] localte: Fix UB on collate_finish
Andreas Schwab
schwab@suse.de
Wed May 7 14:40:14 GMT 2025
On Mai 07 2025, Adhemerval Zanella wrote:
> diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c
> index 4fa08bd273..5ed03f4cbf 100644
> --- a/locale/programs/ld-collate.c
> +++ b/locale/programs/ld-collate.c
> @@ -1554,7 +1554,7 @@ collate_finish (struct localedef_t *locale, const struct charmap_t *charmap)
> The multibyte case is easy. We simply sort into an array with
> 256 elements. */
> struct locale_collate_t *collate = locale->categories[LC_COLLATE].collate;
> - int mbact[nrules];
> + int mbact[nrules == 0 ? 1 : nrules];
nrules is guaranteed to be at most sizeof (((struct element_t *)
0)->used_in_level) * 8, so this can use a fixed array.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
More information about the Libc-alpha
mailing list