From patchwork Fri Jun 25 06:09:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 44009 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 62D6A39BB600 for ; Fri, 25 Jun 2021 06:10:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 62D6A39BB600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1624601410; bh=oIwBg3i8AwDAjMsz+NKnXhBDauMVPJNj+qy9QdwsPmc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=B34gOVIlK4h2SwFjfDEEvuOJ9ZY6BAzEllC5Ck52BPt0o+5XSlE0zNpRDzq4GH5/B pSY5793INtO3JCBMM6mZ0voriukmYQJ/Jr4FYOthRNMX8/MmdsY58/8ybuF+8l9KD3 y2nloCGMwxK5MVSOo9vPZOANLNDpNDlzmoHQZhZs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org 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 To: libc-alpha@sourceware.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 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-Patchwork-Original-From: Siddhesh Poyarekar via Libc-alpha From: Siddhesh Poyarekar Reply-To: Siddhesh Poyarekar Cc: schwab@linux-m68k.org Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" 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 < sizeof (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) /* Add the prefix before sending it off to the parser. */ char *fulldir = xmalloc (prefix_len + dirlen + 2); - char *cp = mempcpy (mempcpy (fulldir, prefix, prefix_len), dir, dirlen); + char *cp = fulldir; + if (dir[0] == '/') + cp = mempcpy (cp, prefix, prefix_len); + cp = stpcpy (cp, dir); if (dir[dirlen - 1] != '/') { @@ -667,8 +670,6 @@ handle_dir (const char *dir) found = gconv_parseconfdir (fulldir, dirlen + prefix_len); - free (fulldir); - if (!found) { error (0, errno, "failed to open gconv configuration files in `%s'",