From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id 367C93851508; Thu, 27 Oct 2022 13:56:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 367C93851508 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666879009; bh=zWB++Q/mEGc83ls+Pes/diUxhuT9tFgc5U8L1BZZDrY=; h=From:To:Subject:Date:From; b=Hd3/5Pu05aO+8eYG2NhGdlyeGlDKMDKLa8Cs8iD+Ap1cyKuVzSPfZjV7oFiqbgynn VAkT95V2sPfR2ZsooVk52HoMdKVsvFXgtnAdqIekLQzZPjhsCn+Cw52wgrjRWH2FAw ScWEd7B3TP52wKLvgklcUY+BoUwbjWkp3iGQERT0= 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: 6de52d57a1dd1f85ccd9bdbb3c5231e36dd00a99 X-Git-Newrev: cf06645316e11077afbc9731693fd19e55619f59 Message-Id: <20221027135649.367C93851508@sourceware.org> Date: Thu, 27 Oct 2022 13:56:49 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=cf06645316e11077afbc9731693fd19e55619f59 commit cf06645316e11077afbc9731693fd19e55619f59 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); } }