From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id 278373851165; Wed, 12 Oct 2022 14:15:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 278373851165 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665584150; bh=+X0oqHNAqhPj5RXM6txMilyzMt6D9ZRA34O/zk6/TSQ=; h=From:To:Subject:Date:From; b=ipwdpy0WE7rSodrUHVmsoDjBQYMVkAQ7HSiaTX4D/Q6/96MntlZnQ/m2FztoOeYbx deN2zslovM0T9qiyIWIo8dwECIX4CvUdoCACitIucOJA7VT6NGP4zx8ZWCHxTxFFUP 7qVqIiOhObQpHTvH8xl4Xbcdrf8UDnPr/GsxBcro= 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: 059dd1983c8ee1a01c556e3dbe412791f43c2b8a X-Git-Newrev: 85c6eba32a3c1f227ff89bbd23d6c97cdf76892b Message-Id: <20221012141550.278373851165@sourceware.org> Date: Wed, 12 Oct 2022 14:15:50 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=85c6eba32a3c1f227ff89bbd23d6c97cdf76892b commit 85c6eba32a3c1f227ff89bbd23d6c97cdf76892b 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. */