From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dog.birch.relay.mailchannels.net (dog.birch.relay.mailchannels.net [23.83.209.48]) by sourceware.org (Postfix) with ESMTPS id 46EA43858006 for ; Fri, 25 Jun 2021 06:09:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 46EA43858006 X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 272C97818D1; Fri, 25 Jun 2021 06:09:46 +0000 (UTC) Received: from pdx1-sub0-mail-a75.g.dreamhost.com (100-96-16-83.trex-nlb.outbound.svc.cluster.local [100.96.16.83]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id A03057811C2; Fri, 25 Jun 2021 06:09:45 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a75.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.96.16.83 (trex/6.3.3); Fri, 25 Jun 2021 06:09:46 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Tangy-Power: 248e93cf32d4f1b3_1624601385893_914948800 X-MC-Loop-Signature: 1624601385893:2474713769 X-MC-Ingress-Time: 1624601385893 Received: from pdx1-sub0-mail-a75.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a75.g.dreamhost.com (Postfix) with ESMTP id 6A6338C382; Thu, 24 Jun 2021 23:09:45 -0700 (PDT) Received: from rhbox.intra.reserved-bit.com (unknown [1.186.101.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a75.g.dreamhost.com (Postfix) with ESMTPSA id 7B2AE8C381; Thu, 24 Jun 2021 23:09:41 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a75 From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Cc: schwab@linux-m68k.org Subject: [PATCH] iconvconfig: Fix multiple issues Date: Fri, 25 Jun 2021 11:39:13 +0530 Message-Id: <20210625060913.300418-1-siddhesh@sourceware.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3494.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jun 2021 06:09:49 -0000 It was noticed on big-endian systems that msgfmt would fail with the following error: msgfmt: gconv_builtin.c:70: __gconv_get_builtin_trans: Assertion `cnt < s= izeof (map) / sizeof (map[0])' failed. Aborted (core dumped) This is only seen on installed systems because it was due to a corrupted gconv-modules.cache. iconvconfig had the following issues (it was specifically freeing fulldir that caused this issue, but other cleanups are also needed) that this patch fixes. - Add prefix only if dir starts with '/' - Use stpcpy instead of mempcpy so that the directory string is NULL terminated - Do not free fulldir because it is used later while writing out the gconv-modules.cache file. --- iconv/iconvconfig.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/iconv/iconvconfig.c b/iconv/iconvconfig.c index e69334d71c..afc40d06cb 100644 --- a/iconv/iconvconfig.c +++ b/iconv/iconvconfig.c @@ -656,7 +656,10 @@ handle_dir (const char *dir) =20 /* Add the prefix before sending it off to the parser. */ char *fulldir =3D xmalloc (prefix_len + dirlen + 2); - char *cp =3D mempcpy (mempcpy (fulldir, prefix, prefix_len), dir, dirl= en); + char *cp =3D fulldir; + if (dir[0] =3D=3D '/') + cp =3D mempcpy (cp, prefix, prefix_len); + cp =3D stpcpy (cp, dir); =20 if (dir[dirlen - 1] !=3D '/') { @@ -667,8 +670,6 @@ handle_dir (const char *dir) =20 found =3D gconv_parseconfdir (fulldir, dirlen + prefix_len); =20 - free (fulldir); - if (!found) { error (0, errno, "failed to open gconv configuration files in `%s'= ", --=20 2.31.1