From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id 31A193857363; Fri, 5 Aug 2022 19:35:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 31A193857363 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] cheri: fix invalid pointer use after realloc in localealias X-Act-Checkin: glibc X-Git-Author: Szabolcs Nagy X-Git-Refname: refs/heads/arm/morello/main X-Git-Oldrev: 68822420a6da19adf0030ddc836c6968b071b467 X-Git-Newrev: d0db1e8a122459e0f37b97eeca2bf399cadb043e Message-Id: <20220805193525.31A193857363@sourceware.org> Date: Fri, 5 Aug 2022 19:35:25 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Aug 2022 19:35:25 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d0db1e8a122459e0f37b97eeca2bf399cadb043e commit d0db1e8a122459e0f37b97eeca2bf399cadb043e Author: Szabolcs Nagy Date: Fri Mar 18 06:55:31 2022 +0000 cheri: fix invalid pointer use after realloc in localealias This code updates pointers to a reallocated buffer to point to the new buffer. It is not conforming (does arithmetics with freed pointers), but it also creates invalid capabilities because the provenance is derived from the original freed pointers instead of the new buffer. Change the arithmetics so provenance is derived from the new buffer. The conformance issue is not fixed. Diff: --- intl/localealias.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/intl/localealias.c b/intl/localealias.c index b36092363a..0401f35f9d 100644 --- a/intl/localealias.c +++ b/intl/localealias.c @@ -340,8 +340,10 @@ read_alias_file (const char *fname, int fname_len) for (i = 0; i < nmap; i++) { - map[i].alias += new_pool - string_space; - map[i].value += new_pool - string_space; + map[i].alias = new_pool + + (map[i].alias - string_space); + map[i].value = new_pool + + (map[i].value - string_space); } }