mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-12 12:10:16 +00:00
Fix OOB read in stdlib thousand separator handling
__correctly_grouped_prefixmb only worked with thousands_len == 1, otherwise it read past the end of cp or thousands. Avoid OOB access by considering thousands_len when initializing cp. On morello with strict bounds checking this fixes FAIL: stdlib/tst-strtod4 FAIL: stdlib/tst-strtod5i both of which set cs_CZ.UTF-8 locale that has 3 byte thousands_len.
This commit is contained in:
parent
059dd1983c
commit
85c6eba32a
@ -64,9 +64,17 @@ __correctly_grouped_prefixmb (const STRING_TYPE *begin, const STRING_TYPE *end,
|
|||||||
thousands_len = strlen (thousands);
|
thousands_len = strlen (thousands);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_WIDE_CHAR
|
||||||
while (end > begin)
|
while (end > begin)
|
||||||
|
#else
|
||||||
|
while (end - begin >= thousands_len)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
#ifdef USE_WIDE_CHAR
|
||||||
const STRING_TYPE *cp = end - 1;
|
const STRING_TYPE *cp = end - 1;
|
||||||
|
#else
|
||||||
|
const STRING_TYPE *cp = end - thousands_len;
|
||||||
|
#endif
|
||||||
const char *gp = grouping;
|
const char *gp = grouping;
|
||||||
|
|
||||||
/* Check first group. */
|
/* Check first group. */
|
||||||
|
Loading…
Reference in New Issue
Block a user