From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id 14942385151F; Wed, 26 Oct 2022 15:11:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 14942385151F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666797063; bh=xXXNnRHzdlztARtaqSbSIHe5k2BgS+SZmDvxK1hFEmA=; h=From:To:Subject:Date:From; b=CdDzEs3MjysR0g2EooYrEu6HRwihS1Z3A/UewvPAoECkFXc2hnV+PJeK0NlLbgJmT p6K2dCiwYHXTNQZnLGX4ORo7u1JavIUAXywQIDiSsE3Nd0YZGrOsiI4Rg/P8mLj7dm f6uireZRj0mlcYuw09wdYzki2tjJwv6d6BZhmg0A= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Szabolcs Nagy To: glibc-cvs@sourceware.org Subject: [glibc/arm/morello/main] Fix OOB read in stdlib thousand separator handling X-Act-Checkin: glibc X-Git-Author: Szabolcs Nagy X-Git-Refname: refs/heads/arm/morello/main X-Git-Oldrev: 11a22680b7409018f85c11119c477c063625b405 X-Git-Newrev: a3bae65b44690a5ca63fbe7ce77fa4269467bde4 Message-Id: <20221026151103.14942385151F@sourceware.org> Date: Wed, 26 Oct 2022 15:11:03 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a3bae65b44690a5ca63fbe7ce77fa4269467bde4 commit a3bae65b44690a5ca63fbe7ce77fa4269467bde4 Author: Szabolcs Nagy 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. */