public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/arm/morello/main] Fix OOB read in stdlib thousand separator handling
@ 2022-10-12 14:15 Szabolcs Nagy
0 siblings, 0 replies; 2+ messages in thread
From: Szabolcs Nagy @ 2022-10-12 14:15 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=85c6eba32a3c1f227ff89bbd23d6c97cdf76892b
commit 85c6eba32a3c1f227ff89bbd23d6c97cdf76892b
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date: Tue Oct 11 15:24:41 2022 +0100
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.
Diff:
---
stdlib/grouping.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/stdlib/grouping.c b/stdlib/grouping.c
index be7922f5fd..4622897488 100644
--- a/stdlib/grouping.c
+++ b/stdlib/grouping.c
@@ -64,9 +64,17 @@ __correctly_grouped_prefixmb (const STRING_TYPE *begin, const STRING_TYPE *end,
thousands_len = strlen (thousands);
#endif
+#ifdef USE_WIDE_CHAR
while (end > begin)
+#else
+ while (end - begin >= thousands_len)
+#endif
{
+#ifdef USE_WIDE_CHAR
const STRING_TYPE *cp = end - 1;
+#else
+ const STRING_TYPE *cp = end - thousands_len;
+#endif
const char *gp = grouping;
/* Check first group. */
^ permalink raw reply [flat|nested] 2+ messages in thread
* [glibc/arm/morello/main] Fix OOB read in stdlib thousand separator handling
@ 2022-10-26 15:11 Szabolcs Nagy
0 siblings, 0 replies; 2+ messages in thread
From: Szabolcs Nagy @ 2022-10-26 15:11 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a3bae65b44690a5ca63fbe7ce77fa4269467bde4
commit a3bae65b44690a5ca63fbe7ce77fa4269467bde4
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date: Tue Oct 11 15:24:41 2022 +0100
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.
Diff:
---
stdlib/grouping.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/stdlib/grouping.c b/stdlib/grouping.c
index be7922f5fd..4622897488 100644
--- a/stdlib/grouping.c
+++ b/stdlib/grouping.c
@@ -64,9 +64,17 @@ __correctly_grouped_prefixmb (const STRING_TYPE *begin, const STRING_TYPE *end,
thousands_len = strlen (thousands);
#endif
+#ifdef USE_WIDE_CHAR
while (end > begin)
+#else
+ while (end - begin >= thousands_len)
+#endif
{
+#ifdef USE_WIDE_CHAR
const STRING_TYPE *cp = end - 1;
+#else
+ const STRING_TYPE *cp = end - thousands_len;
+#endif
const char *gp = grouping;
/* Check first group. */
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-26 15:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-12 14:15 [glibc/arm/morello/main] Fix OOB read in stdlib thousand separator handling Szabolcs Nagy
2022-10-26 15:11 Szabolcs Nagy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).