From patchwork Tue Jun 22 05:11:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1495447 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=BBv49AeV; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G8F0l3yG9z9sj5 for ; Tue, 22 Jun 2021 15:13:27 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D2122385501E for ; Tue, 22 Jun 2021 05:13:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D2122385501E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1624338804; bh=8giCMhpTYlQEF+awMGJyN3TQfAWc8T8rTZ56/qbGKMw=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=BBv49AeVjyravGWphhzNHzrHsN2VotDTXVXYr5Y93Ar5L2bO4bNahfmebSS/vViGD uYBdapCrfl6WlTM7lLSgRFA73KgrkpSLCkoHhGH0bmlFGCGyAhLlIMXduji8jbxF2z T61F3HjzR53wYohUsKKPw9ka41QAwv+B9BEcp/v0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from antelope.elm.relay.mailchannels.net (antelope.elm.relay.mailchannels.net [23.83.212.4]) by sourceware.org (Postfix) with ESMTPS id 2741E393D009 for ; Tue, 22 Jun 2021 05:12:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2741E393D009 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 039C3401AF7; Tue, 22 Jun 2021 05:12:26 +0000 (UTC) Received: from pdx1-sub0-mail-a46.g.dreamhost.com (100-96-18-93.trex.outbound.svc.cluster.local [100.96.18.93]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 1BFB740216E; Tue, 22 Jun 2021 05:12:25 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a46.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.96.18.93 (trex/6.3.3); Tue, 22 Jun 2021 05:12:25 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Celery-Trade: 7462e89e773ab9c3_1624338745827_796092678 X-MC-Loop-Signature: 1624338745827:1331750803 X-MC-Ingress-Time: 1624338745826 Received: from pdx1-sub0-mail-a46.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a46.g.dreamhost.com (Postfix) with ESMTP id D45C0880B4; Mon, 21 Jun 2021 22:12:24 -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-a46.g.dreamhost.com (Postfix) with ESMTPSA id EBA3E7F50D; Mon, 21 Jun 2021 22:12:22 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a46 To: libc-alpha@sourceware.org Subject: [PATCH v2 1/6] iconv: Remove alloca use in gconv-modules configuration parsing Date: Tue, 22 Jun 2021 10:41:57 +0530 Message-Id: <20210622051202.4155709-2-siddhesh@sourceware.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210622051202.4155709-1-siddhesh@sourceware.org> References: <20210622051202.4155709-1-siddhesh@sourceware.org> 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 Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" The alloca sizes ought to be constrained to PATH_MAX, but replace them with dynamic allocation to be safe. A static PATH_MAX array would have worked too but Hurd does not have PATH_MAX and the code path is not hot enough to micro-optimise this allocation. Revisit if any of those realities change. Reviewed-by: DJ Delorie --- iconv/gconv_conf.c | 17 +++++++++-------- iconv/iconvconfig.c | 17 +++++++++++------ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c index c8ad8099a4..3f2cef255b 100644 --- a/iconv/gconv_conf.c +++ b/iconv/gconv_conf.c @@ -559,15 +559,15 @@ __gconv_read_conf (void) for (cnt = 0; __gconv_path_elem[cnt].name != NULL; ++cnt) { -#define BUF_LEN elem_len + sizeof (gconv_conf_dirname) - const char *elem = __gconv_path_elem[cnt].name; size_t elem_len = __gconv_path_elem[cnt].len; - char *buf; /* No slash needs to be inserted between elem and gconv_conf_filename; elem already ends in a slash. */ - buf = alloca (BUF_LEN); + char *buf = malloc (elem_len + sizeof (gconv_conf_dirname)); + if (buf == NULL) + continue; + char *cp = __mempcpy (__mempcpy (buf, elem, elem_len), gconv_conf_filename, sizeof (gconv_conf_filename)); @@ -596,15 +596,16 @@ __gconv_read_conf (void) if (len > strlen (suffix) && strcmp (ent->d_name + len - strlen (suffix), suffix) == 0) { - /* LEN <= PATH_MAX so this alloca is not unbounded. */ - char *conf = alloca (BUF_LEN + len + 1); - cp = stpcpy (conf, buf); - sprintf (cp, "/%s", ent->d_name); + char *conf; + if (__asprintf (&conf, "%s/%s", buf, ent->d_name) < 0) + continue; read_conf_file (conf, elem, elem_len, &modules, &nmodules); + free (conf); } } __closedir (confdir); } + free (buf); } #endif diff --git a/iconv/iconvconfig.c b/iconv/iconvconfig.c index b2a868919c..c9607fb645 100644 --- a/iconv/iconvconfig.c +++ b/iconv/iconvconfig.c @@ -712,7 +712,6 @@ handle_file (const char *dir, const char *infile) static int handle_dir (const char *dir) { -#define BUF_LEN prefix_len + dirlen + sizeof "gconv-modules.d" char *cp; size_t dirlen = strlen (dir); bool found = false; @@ -726,7 +725,10 @@ handle_dir (const char *dir) } /* First, look for a gconv-modules file. */ - char buf[BUF_LEN]; + char *buf = malloc (prefix_len + dirlen + sizeof "gconv-modules.d"); + if (buf == NULL) + goto out; + cp = buf; if (dir[0] == '/') cp = mempcpy (cp, prefix, prefix_len); @@ -756,16 +758,19 @@ handle_dir (const char *dir) if (len > strlen (suffix) && strcmp (ent->d_name + len - strlen (suffix), suffix) == 0) { - /* LEN <= PATH_MAX so this alloca is not unbounded. */ - char *conf = alloca (BUF_LEN + len + 1); - cp = stpcpy (conf, buf); - sprintf (cp, "/%s", ent->d_name); + char *conf; + if (asprintf (&conf, "%s/%s", buf, ent->d_name) < 0) + continue; found |= handle_file (dir, conf); + free (conf); } } closedir (confdir); } + free (buf); + +out: if (!found) { error (0, errno, "failed to open gconv configuration files in `%s'", From patchwork Tue Jun 22 05:11:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1495448 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=XKcki5O2; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G8F1c3yfBz9sj5 for ; Tue, 22 Jun 2021 15:14:12 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 247853945C31 for ; Tue, 22 Jun 2021 05:14:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 247853945C31 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1624338850; bh=znn4lR98a6ToK/+6AAtHU0ysG5rEOHeK2MPhPtTwpck=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=XKcki5O2RYxNnG9moSJxOP++UZqXh80hII5DoMkF+VoIc/TI9if3pK2Ge6flx4/R+ Uq9UBaN0BzB26Z+TMUiJktcVymzXqyVIorReawJVSHyn9mE3Im32jI9W/1ou86X7dt 8vxe4VnhcU+3kjKYe+02vj4bive1otH+03B7xCNM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from quail.birch.relay.mailchannels.net (quail.birch.relay.mailchannels.net [23.83.209.151]) by sourceware.org (Postfix) with ESMTPS id D5E593945C10 for ; Tue, 22 Jun 2021 05:12:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D5E593945C10 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 780BC922D6B; Tue, 22 Jun 2021 05:12:29 +0000 (UTC) Received: from pdx1-sub0-mail-a46.g.dreamhost.com (100-98-55-86.trex.outbound.svc.cluster.local [100.98.55.86]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id CA503922D53; Tue, 22 Jun 2021 05:12:28 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a46.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.98.55.86 (trex/6.3.3); Tue, 22 Jun 2021 05:12:29 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Bitter-Quick: 48216f8a68f9fdb0_1624338749258_3499502958 X-MC-Loop-Signature: 1624338749258:3808217085 X-MC-Ingress-Time: 1624338749257 Received: from pdx1-sub0-mail-a46.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a46.g.dreamhost.com (Postfix) with ESMTP id 65D7A880B4; Mon, 21 Jun 2021 22:12:28 -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-a46.g.dreamhost.com (Postfix) with ESMTPSA id 993D37F50D; Mon, 21 Jun 2021 22:12:25 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a46 To: libc-alpha@sourceware.org Subject: [PATCH v2 2/6] gconv_conf: Remove unused variables Date: Tue, 22 Jun 2021 10:41:58 +0530 Message-Id: <20210622051202.4155709-3-siddhesh@sourceware.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210622051202.4155709-1-siddhesh@sourceware.org> References: <20210622051202.4155709-1-siddhesh@sourceware.org> 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: Andreas Schwab Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" The modules and nmodules parameters passed to add_modules, add_alias, etc. are not used and are hence unnecessary. Remove them so that their signatures match the functions in iconvconfig. Reviewed-by: DJ Delorie Reviewed-by: Andreas Schwab --- iconv/gconv_conf.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c index 3f2cef255b..6c6625c37a 100644 --- a/iconv/gconv_conf.c +++ b/iconv/gconv_conf.c @@ -132,7 +132,7 @@ detect_conflict (const char *alias) /* The actual code to add aliases. */ static void -add_alias2 (const char *from, const char *to, const char *wp, void *modules) +add_alias2 (const char *from, const char *to, const char *wp) { /* Test whether this alias conflicts with any available module. */ if (detect_conflict (from)) @@ -161,7 +161,7 @@ add_alias2 (const char *from, const char *to, const char *wp, void *modules) /* Add new alias. */ static void -add_alias (char *rp, void *modules) +add_alias (char *rp) { /* We now expect two more string. The strings are normalized (converted to UPPER case) and strored in the alias database. */ @@ -186,7 +186,7 @@ add_alias (char *rp, void *modules) return; *wp++ = '\0'; - add_alias2 (from, to, wp, modules); + add_alias2 (from, to, wp); } @@ -250,8 +250,7 @@ insert_module (struct gconv_module *newp, int tobefreed) /* Add new module. */ static void -add_module (char *rp, const char *directory, size_t dir_len, void **modules, - size_t *nmodules, int modcounter) +add_module (char *rp, const char *directory, size_t dir_len, int modcounter) { /* We expect now 1. `from' name @@ -364,8 +363,7 @@ add_module (char *rp, const char *directory, size_t dir_len, void **modules, /* Read the next configuration file. */ static void -read_conf_file (const char *filename, const char *directory, size_t dir_len, - void **modules, size_t *nmodules) +read_conf_file (const char *filename, const char *directory, size_t dir_len) { /* Note the file is opened with cancellation in the I/O functions disabled. */ @@ -415,10 +413,10 @@ read_conf_file (const char *filename, const char *directory, size_t dir_len, if (rp - word == sizeof ("alias") - 1 && memcmp (word, "alias", sizeof ("alias") - 1) == 0) - add_alias (rp, *modules); + add_alias (rp); else if (rp - word == sizeof ("module") - 1 && memcmp (word, "module", sizeof ("module") - 1) == 0) - add_module (rp, directory, dir_len, modules, nmodules, modcounter++); + add_module (rp, directory, dir_len, modcounter++); /* else */ /* Otherwise ignore the line. */ } @@ -540,8 +538,6 @@ __gconv_get_path (void) static void __gconv_read_conf (void) { - void *modules = NULL; - size_t nmodules = 0; int save_errno = errno; size_t cnt; @@ -572,7 +568,7 @@ __gconv_read_conf (void) gconv_conf_filename, sizeof (gconv_conf_filename)); /* Read the gconv-modules configuration file first. */ - read_conf_file (buf, elem, elem_len, &modules, &nmodules); + read_conf_file (buf, elem, elem_len); /* Next, see if there is a gconv-modules.d directory containing configuration files and if it is non-empty. */ @@ -599,7 +595,7 @@ __gconv_read_conf (void) char *conf; if (__asprintf (&conf, "%s/%s", buf, ent->d_name) < 0) continue; - read_conf_file (conf, elem, elem_len, &modules, &nmodules); + read_conf_file (conf, elem, elem_len); free (conf); } } @@ -633,7 +629,7 @@ __gconv_read_conf (void) const char *to = __rawmemchr (from, '\0') + 1; cp = __rawmemchr (to, '\0') + 1; - add_alias2 (from, to, cp, modules); + add_alias2 (from, to, cp); } while (*cp != '\0'); From patchwork Tue Jun 22 05:11:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1495449 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=dDVkB6lc; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G8F2c4rRFz9sjB for ; Tue, 22 Jun 2021 15:15:04 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5E84D3947410 for ; Tue, 22 Jun 2021 05:15:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5E84D3947410 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1624338902; bh=7zxKHhaMb1kqOtcCNobncBgs9upcmYil42agcS97dwY=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=dDVkB6lcURq8id7xgr+U82OtVFyqIo+9Xt+LH77CB5sb4nGJkTOidiUsNei1BWnRg KhLGgIA/LxpetFtzu4X3S8gl9g++dEAYUOrR8S4PP58r6+yRT8t8PBcISbGF18nFTq uigrk1YZVOjcSpDVXovHeqS0DDGKHhJJ3WXOPhto= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from eastern.birch.relay.mailchannels.net (eastern.birch.relay.mailchannels.net [23.83.209.55]) by sourceware.org (Postfix) with ESMTPS id 16E5E3945C20 for ; Tue, 22 Jun 2021 05:12:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 16E5E3945C20 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 10DE5781622; Tue, 22 Jun 2021 05:12:31 +0000 (UTC) Received: from pdx1-sub0-mail-a46.g.dreamhost.com (100-96-18-93.trex.outbound.svc.cluster.local [100.96.18.93]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 95A70781711; Tue, 22 Jun 2021 05:12:30 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a46.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.96.18.93 (trex/6.3.3); Tue, 22 Jun 2021 05:12:31 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Coil-Abortive: 2f542de944a52f16_1624338750863_1074920130 X-MC-Loop-Signature: 1624338750863:2293342938 X-MC-Ingress-Time: 1624338750863 Received: from pdx1-sub0-mail-a46.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a46.g.dreamhost.com (Postfix) with ESMTP id 56DD0880B4; Mon, 21 Jun 2021 22:12:30 -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-a46.g.dreamhost.com (Postfix) with ESMTPSA id 01B0F7F50D; Mon, 21 Jun 2021 22:12:28 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a46 To: libc-alpha@sourceware.org Subject: [PATCH v2 3/6] gconv_conf: Split out configuration file processing Date: Tue, 22 Jun 2021 10:41:59 +0530 Message-Id: <20210622051202.4155709-4-siddhesh@sourceware.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210622051202.4155709-1-siddhesh@sourceware.org> References: <20210622051202.4155709-1-siddhesh@sourceware.org> 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, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Split configuration file processing into a separate header file and include it. Macroize all calls that need to go through internal interfaces so that iconvconfig can also use them. Reviewed-by: DJ Delorie --- iconv/gconv_conf.c | 129 +---------------------------- iconv/gconv_parseconfdir.h | 161 +++++++++++++++++++++++++++++++++++++ 2 files changed, 164 insertions(+), 126 deletions(-) create mode 100644 iconv/gconv_parseconfdir.h diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c index 6c6625c37a..62bee28769 100644 --- a/iconv/gconv_conf.c +++ b/iconv/gconv_conf.c @@ -19,7 +19,6 @@ #include #include -#include #include #include #include @@ -31,11 +30,10 @@ #include #include #include -#include #include #include - +#include /* This is the default path where we look for module lists. */ static const char default_gconv_path[] = GCONV_PATH; @@ -56,11 +54,6 @@ size_t __gconv_max_path_elem_len; /* We use the following struct if we couldn't allocate memory. */ static const struct path_elem empty_path_elem = { NULL, 0 }; -/* Name of the file containing the module information in the directories - along the path. */ -static const char gconv_conf_filename[] = "gconv-modules"; -static const char gconv_conf_dirname[] = "gconv-modules.d"; - /* Filename extension for the modules. */ #ifndef MODULE_EXT # define MODULE_EXT ".so" @@ -99,9 +92,6 @@ static const char builtin_aliases[] = #undef BUILTIN_ALIAS }; -#include -#define __getdelim(line, len, c, fp) _IO_getdelim (line, len, c, fp) - /* Value of the GCONV_PATH environment variable. */ const char *__gconv_path_envvar; @@ -361,72 +351,6 @@ add_module (char *rp, const char *directory, size_t dir_len, int modcounter) } -/* Read the next configuration file. */ -static void -read_conf_file (const char *filename, const char *directory, size_t dir_len) -{ - /* Note the file is opened with cancellation in the I/O functions - disabled. */ - FILE *fp = fopen (filename, "rce"); - char *line = NULL; - size_t line_len = 0; - static int modcounter; - - /* Don't complain if a file is not present or readable, simply silently - ignore it. */ - if (fp == NULL) - return; - - /* No threads reading from this stream. */ - __fsetlocking (fp, FSETLOCKING_BYCALLER); - - /* Process the known entries of the file. Comments start with `#' and - end with the end of the line. Empty lines are ignored. */ - while (!__feof_unlocked (fp)) - { - char *rp, *endp, *word; - ssize_t n = __getdelim (&line, &line_len, '\n', fp); - if (n < 0) - /* An error occurred. */ - break; - - rp = line; - /* Terminate the line (excluding comments or newline) by an NUL byte - to simplify the following code. */ - endp = strchr (rp, '#'); - if (endp != NULL) - *endp = '\0'; - else - if (rp[n - 1] == '\n') - rp[n - 1] = '\0'; - - while (__isspace_l (*rp, _nl_C_locobj_ptr)) - ++rp; - - /* If this is an empty line go on with the next one. */ - if (rp == endp) - continue; - - word = rp; - while (*rp != '\0' && !__isspace_l (*rp, _nl_C_locobj_ptr)) - ++rp; - - if (rp - word == sizeof ("alias") - 1 - && memcmp (word, "alias", sizeof ("alias") - 1) == 0) - add_alias (rp); - else if (rp - word == sizeof ("module") - 1 - && memcmp (word, "module", sizeof ("module") - 1) == 0) - add_module (rp, directory, dir_len, modcounter++); - /* else */ - /* Otherwise ignore the line. */ - } - - free (line); - - fclose (fp); -} - - /* Determine the directories we are looking for data in. This function should only be called from __gconv_read_conf. */ static void @@ -554,55 +478,8 @@ __gconv_read_conf (void) __gconv_get_path (); for (cnt = 0; __gconv_path_elem[cnt].name != NULL; ++cnt) - { - const char *elem = __gconv_path_elem[cnt].name; - size_t elem_len = __gconv_path_elem[cnt].len; - - /* No slash needs to be inserted between elem and gconv_conf_filename; - elem already ends in a slash. */ - char *buf = malloc (elem_len + sizeof (gconv_conf_dirname)); - if (buf == NULL) - continue; - - char *cp = __mempcpy (__mempcpy (buf, elem, elem_len), - gconv_conf_filename, sizeof (gconv_conf_filename)); - - /* Read the gconv-modules configuration file first. */ - read_conf_file (buf, elem, elem_len); - - /* Next, see if there is a gconv-modules.d directory containing - configuration files and if it is non-empty. */ - cp--; - cp[0] = '.'; - cp[1] = 'd'; - cp[2] = '\0'; - - DIR *confdir = __opendir (buf); - if (confdir != NULL) - { - struct dirent *ent; - while ((ent = __readdir (confdir)) != NULL) - { - if (ent->d_type != DT_REG) - continue; - - size_t len = strlen (ent->d_name); - const char *suffix = ".conf"; - - if (len > strlen (suffix) - && strcmp (ent->d_name + len - strlen (suffix), suffix) == 0) - { - char *conf; - if (__asprintf (&conf, "%s/%s", buf, ent->d_name) < 0) - continue; - read_conf_file (conf, elem, elem_len); - free (conf); - } - } - __closedir (confdir); - } - free (buf); - } + gconv_parseconfdir (__gconv_path_elem[cnt].name, + __gconv_path_elem[cnt].len); #endif /* Add the internal modules. */ diff --git a/iconv/gconv_parseconfdir.h b/iconv/gconv_parseconfdir.h new file mode 100644 index 0000000000..3d4d58d4be --- /dev/null +++ b/iconv/gconv_parseconfdir.h @@ -0,0 +1,161 @@ +/* Handle configuration data. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include + +#if IS_IN (libc) +# include +# define __getdelim(line, len, c, fp) _IO_getdelim (line, len, c, fp) + +# undef isspace +# define isspace(__c) __isspace_l ((__c), _nl_C_locobj_ptr) +# define asprintf __asprintf +# define opendir __opendir +# define readdir __readdir +# define closedir __closedir +# define mempcpy __mempcpy +#endif + +/* Name of the file containing the module information in the directories + along the path. */ +static const char gconv_conf_filename[] = "gconv-modules"; +static const char gconv_conf_dirname[] = "gconv-modules.d"; + +static void add_alias (char *); +static void add_module (char *, const char *, size_t, int); + +/* Read the next configuration file. */ +static bool +read_conf_file (const char *filename, const char *directory, size_t dir_len) +{ + /* Note the file is opened with cancellation in the I/O functions + disabled. */ + FILE *fp = fopen (filename, "rce"); + char *line = NULL; + size_t line_len = 0; + static int modcounter; + + /* Don't complain if a file is not present or readable, simply silently + ignore it. */ + if (fp == NULL) + return false; + + /* No threads reading from this stream. */ + __fsetlocking (fp, FSETLOCKING_BYCALLER); + + /* Process the known entries of the file. Comments start with `#' and + end with the end of the line. Empty lines are ignored. */ + while (!__feof_unlocked (fp)) + { + char *rp, *endp, *word; + ssize_t n = __getdelim (&line, &line_len, '\n', fp); + if (n < 0) + /* An error occurred. */ + break; + + rp = line; + /* Terminate the line (excluding comments or newline) by an NUL byte + to simplify the following code. */ + endp = strchr (rp, '#'); + if (endp != NULL) + *endp = '\0'; + else + if (rp[n - 1] == '\n') + rp[n - 1] = '\0'; + + while (isspace (*rp)) + ++rp; + + /* If this is an empty line go on with the next one. */ + if (rp == endp) + continue; + + word = rp; + while (*rp != '\0' && !isspace (*rp)) + ++rp; + + if (rp - word == sizeof ("alias") - 1 + && memcmp (word, "alias", sizeof ("alias") - 1) == 0) + add_alias (rp); + else if (rp - word == sizeof ("module") - 1 + && memcmp (word, "module", sizeof ("module") - 1) == 0) + add_module (rp, directory, dir_len, modcounter++); + /* else */ + /* Otherwise ignore the line. */ + } + + free (line); + + fclose (fp); + return true; +} + +static __always_inline bool +gconv_parseconfdir (const char *dir, size_t dir_len) +{ + /* No slash needs to be inserted between dir and gconv_conf_filename; + dir already ends in a slash. */ + char *buf = malloc (dir_len + sizeof (gconv_conf_dirname)); + bool found = false; + + if (buf == NULL) + return false; + + char *cp = mempcpy (mempcpy (buf, dir, dir_len), gconv_conf_filename, + sizeof (gconv_conf_filename)); + + /* Read the gconv-modules configuration file first. */ + found = read_conf_file (buf, dir, dir_len); + + /* Next, see if there is a gconv-modules.d directory containing + configuration files and if it is non-empty. */ + cp--; + cp[0] = '.'; + cp[1] = 'd'; + cp[2] = '\0'; + + DIR *confdir = opendir (buf); + if (confdir != NULL) + { + struct dirent *ent; + while ((ent = readdir (confdir)) != NULL) + { + if (ent->d_type != DT_REG) + continue; + + size_t len = strlen (ent->d_name); + const char *suffix = ".conf"; + + if (len > strlen (suffix) + && strcmp (ent->d_name + len - strlen (suffix), suffix) == 0) + { + char *conf; + if (asprintf (&conf, "%s/%s", buf, ent->d_name) < 0) + continue; + found |= read_conf_file (conf, dir, dir_len); + free (conf); + } + } + closedir (confdir); + } + free (buf); + return found; +} From patchwork Tue Jun 22 05:12:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1495450 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=ImTVBi1/; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G8F3T4vF6z9sTD for ; Tue, 22 Jun 2021 15:15:49 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 471E53947414 for ; Tue, 22 Jun 2021 05:15:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 471E53947414 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1624338947; bh=hCWJMFebNmWBc1EotrR3qHXldCT4cHrSmDxmPcq+9Ik=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ImTVBi1/j4AxShCmxELetLeLZ82SnnL3rhqV+qiy5VrlnNCZ9ft3n6bIYv9N0j5Mn HajssfkMGsmQXx1Y7yFM4wuAgr0u5lXnwA81fpMIuAdDlZ3QSj4gICeZBdO6bgCUq3 fP4pl2QS7JDx6bkfEV/GFoIJV/x744+SqusMJQs8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from bird.elm.relay.mailchannels.net (bird.elm.relay.mailchannels.net [23.83.212.17]) by sourceware.org (Postfix) with ESMTPS id 1CA82393D012 for ; Tue, 22 Jun 2021 05:12:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1CA82393D012 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 C91C2121CC6 for ; Tue, 22 Jun 2021 05:12:32 +0000 (UTC) Received: from pdx1-sub0-mail-a46.g.dreamhost.com (100-96-11-21.trex.outbound.svc.cluster.local [100.96.11.21]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 5AB1C12205C for ; Tue, 22 Jun 2021 05:12:32 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a46.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.96.11.21 (trex/6.3.3); Tue, 22 Jun 2021 05:12:32 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Continue-Share: 2e49c655155cf2b6_1624338752593_1487323750 X-MC-Loop-Signature: 1624338752592:277842953 X-MC-Ingress-Time: 1624338752592 Received: from pdx1-sub0-mail-a46.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a46.g.dreamhost.com (Postfix) with ESMTP id 1DC84880B4 for ; Mon, 21 Jun 2021 22:12:32 -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-a46.g.dreamhost.com (Postfix) with ESMTPSA id 27EE07F50D for ; Mon, 21 Jun 2021 22:12:30 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a46 To: libc-alpha@sourceware.org Subject: [PATCH v2 4/6] iconvconfig: Use common gconv module parsing function Date: Tue, 22 Jun 2021 10:42:00 +0530 Message-Id: <20210622051202.4155709-5-siddhesh@sourceware.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210622051202.4155709-1-siddhesh@sourceware.org> References: <20210622051202.4155709-1-siddhesh@sourceware.org> MIME-Version: 1.0 X-Spam-Status: No, score=-3492.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_NONE, 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 Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Drop local copy of gconv file parsing and use the one in gconv_parseconfdir.h instead. Now there is a single implementation of configuration file parsing. Reviewed-by: DJ Delorie --- iconv/iconvconfig.c | 128 +++++--------------------------------------- 1 file changed, 13 insertions(+), 115 deletions(-) diff --git a/iconv/iconvconfig.c b/iconv/iconvconfig.c index c9607fb645..e69334d71c 100644 --- a/iconv/iconvconfig.c +++ b/iconv/iconvconfig.c @@ -18,7 +18,6 @@ #include #include -#include #include #include #include @@ -34,10 +33,10 @@ #include #include #include -#include #include #include "iconvconfig.h" +#include /* Get libc version number. */ #include "../version.h" @@ -568,7 +567,9 @@ new_module (const char *fromname, size_t fromlen, const char *toname, /* Add new module. */ static void -add_module (char *rp, const char *directory) +add_module (char *rp, const char *directory, + size_t dirlen __attribute__ ((__unused__)), + int modcount __attribute__ ((__unused__))) { /* We expect now 1. `from' name @@ -646,131 +647,28 @@ add_module (char *rp, const char *directory) cost, need_ext); } -/* Read a gconv-modules configuration file. */ -static bool -handle_file (const char *dir, const char *infile) -{ - FILE *fp; - char *line = NULL; - size_t linelen = 0; - - fp = fopen (infile, "r"); - if (fp == NULL) - return false; - - /* No threads present. */ - __fsetlocking (fp, FSETLOCKING_BYCALLER); - - while (!feof_unlocked (fp)) - { - char *rp, *endp, *word; - ssize_t n = __getdelim (&line, &linelen, '\n', fp); - - if (n < 0) - /* An error occurred. */ - break; - - rp = line; - /* Terminate the line (excluding comments or newline) with a NUL - byte to simplify the following code. */ - endp = strchr (rp, '#'); - if (endp != NULL) - *endp = '\0'; - else - if (rp[n - 1] == '\n') - rp[n - 1] = '\0'; - - while (isspace (*rp)) - ++rp; - - /* If this is an empty line go on with the next one. */ - if (rp == endp) - continue; - - word = rp; - while (*rp != '\0' && !isspace (*rp)) - ++rp; - - if (rp - word == sizeof ("alias") - 1 - && memcmp (word, "alias", sizeof ("alias") - 1) == 0) - add_alias (rp); - else if (rp - word == sizeof ("module") - 1 - && memcmp (word, "module", sizeof ("module") - 1) == 0) - add_module (rp, dir); - /* else */ - /* Otherwise ignore the line. */ - } - - free (line); - - fclose (fp); - - return true; -} - /* Read config files and add the data for this directory to cache. */ static int handle_dir (const char *dir) { - char *cp; size_t dirlen = strlen (dir); bool found = false; + /* 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); + if (dir[dirlen - 1] != '/') { - char *newp = (char *) xmalloc (dirlen + 2); - dir = memcpy (newp, dir, dirlen); - newp[dirlen++] = '/'; - newp[dirlen] = '\0'; + *cp++ = '/'; + *cp = '\0'; + dirlen++; } - /* First, look for a gconv-modules file. */ - char *buf = malloc (prefix_len + dirlen + sizeof "gconv-modules.d"); - if (buf == NULL) - goto out; - - cp = buf; - if (dir[0] == '/') - cp = mempcpy (cp, prefix, prefix_len); - cp = mempcpy (cp, dir, dirlen); - cp = stpcpy (cp, "gconv-modules"); - - found |= handle_file (dir, buf); - - /* Next, see if there is a gconv-modules.d directory containing configuration - files and if it is non-empty. */ - cp[0] = '.'; - cp[1] = 'd'; - cp[2] = '\0'; - - DIR *confdir = opendir (buf); - if (confdir != NULL) - { - struct dirent *ent; - while ((ent = readdir (confdir)) != NULL) - { - if (ent->d_type != DT_REG) - continue; - - size_t len = strlen (ent->d_name); - const char *suffix = ".conf"; - - if (len > strlen (suffix) - && strcmp (ent->d_name + len - strlen (suffix), suffix) == 0) - { - char *conf; - if (asprintf (&conf, "%s/%s", buf, ent->d_name) < 0) - continue; - found |= handle_file (dir, conf); - free (conf); - } - } - closedir (confdir); - } + found = gconv_parseconfdir (fulldir, dirlen + prefix_len); - free (buf); + free (fulldir); -out: if (!found) { error (0, errno, "failed to open gconv configuration files in `%s'", From patchwork Tue Jun 22 05:12:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1495451 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=W1b3HJH/; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G8F4L4SQGz9sTD for ; Tue, 22 Jun 2021 15:16:34 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 27BE339450FF for ; Tue, 22 Jun 2021 05:16:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 27BE339450FF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1624338992; bh=3LAh8wFQn8MiDv9hDoVKiNcR6D0wbrsKzCXPV2MtHV4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=W1b3HJH/n1baR/sJxT2GrEoqxkE6l5RU45KToBrmhQxpIFnJ3YERwRp46ffsneLe4 OWzIXEaVKCoVHUWoeP5apwRh+laSw+Bl7FOh3Hzznlf46i2Psi8VQ3bIwGjJ4u6Zoj KIsW+fxzf/aOmdh9518H9xcGlFF2BQsfnz5H9S80= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from eastern.birch.relay.mailchannels.net (eastern.birch.relay.mailchannels.net [23.83.209.55]) by sourceware.org (Postfix) with ESMTPS id 710AA383A839 for ; Tue, 22 Jun 2021 05:12:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 710AA383A839 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 6BBD9780795; Tue, 22 Jun 2021 05:12:34 +0000 (UTC) Received: from pdx1-sub0-mail-a46.g.dreamhost.com (100-98-55-86.trex.outbound.svc.cluster.local [100.98.55.86]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 041947813D8; Tue, 22 Jun 2021 05:12:34 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a46.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.98.55.86 (trex/6.3.3); Tue, 22 Jun 2021 05:12:34 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Abiding-Share: 1d0605c855331653_1624338754253_2113386230 X-MC-Loop-Signature: 1624338754253:3181981718 X-MC-Ingress-Time: 1624338754253 Received: from pdx1-sub0-mail-a46.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a46.g.dreamhost.com (Postfix) with ESMTP id BA8B1880B4; Mon, 21 Jun 2021 22:12:33 -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-a46.g.dreamhost.com (Postfix) with ESMTPSA id ACC677F50D; Mon, 21 Jun 2021 22:12:32 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a46 To: libc-alpha@sourceware.org Subject: [PATCH v2 5/6] Handle DT_UNKNOWN in gconv-modules.d Date: Tue, 22 Jun 2021 10:42:01 +0530 Message-Id: <20210622051202.4155709-6-siddhesh@sourceware.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210622051202.4155709-1-siddhesh@sourceware.org> References: <20210622051202.4155709-1-siddhesh@sourceware.org> 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_H3, RCVD_IN_MSPIKE_WL, 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 Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" On filesystems that do not support dt_type, a regular file shows up as DT_UNKNOWN. Fall back to using lstat64 to read file properties in such cases. Reviewed-by: DJ Delorie --- iconv/gconv_parseconfdir.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/iconv/gconv_parseconfdir.h b/iconv/gconv_parseconfdir.h index 3d4d58d4be..e73ea0ff5c 100644 --- a/iconv/gconv_parseconfdir.h +++ b/iconv/gconv_parseconfdir.h @@ -32,6 +32,7 @@ # define readdir __readdir # define closedir __closedir # define mempcpy __mempcpy +# define lstat64 __lstat64 #endif /* Name of the file containing the module information in the directories @@ -138,7 +139,7 @@ gconv_parseconfdir (const char *dir, size_t dir_len) struct dirent *ent; while ((ent = readdir (confdir)) != NULL) { - if (ent->d_type != DT_REG) + if (ent->d_type != DT_REG && ent->d_type != DT_UNKNOWN) continue; size_t len = strlen (ent->d_name); @@ -148,8 +149,14 @@ gconv_parseconfdir (const char *dir, size_t dir_len) && strcmp (ent->d_name + len - strlen (suffix), suffix) == 0) { char *conf; + struct stat64 st; if (asprintf (&conf, "%s/%s", buf, ent->d_name) < 0) continue; + if (ent->d_type == DT_UNKNOWN + && (lstat64 (conf, &st) == -1 + || !S_ISREG (st.st_mode))) + continue; + found |= read_conf_file (conf, dir, dir_len); free (conf); } From patchwork Tue Jun 22 05:12:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1495452 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=h5RZdfnv; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G8F5D1Y7cz9sTD for ; Tue, 22 Jun 2021 15:17:20 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B6F703947418 for ; Tue, 22 Jun 2021 05:17:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B6F703947418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1624339037; bh=DIeo0TIcvrqITOq6ScWzihOI3zYWnZVXpWkkf4u3iW4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=h5RZdfnv0pLYzd3U9i8fnVsjckkyGjKSf8hZSJK3YanZDueF86fOFPTCvd9ddEVvR 9UlcDRGdVUyj75rCXUC9xhJKMwQdc4lWmFoOJ7KJ7+CGOektkyL/AUX84iI5Kfrc6o HyRbJoik7p2PDw82brdIdUJu2Sr9bqbU0p8/USjg= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from hamster.birch.relay.mailchannels.net (hamster.birch.relay.mailchannels.net [23.83.209.80]) by sourceware.org (Postfix) with ESMTPS id 5404A3947406 for ; Tue, 22 Jun 2021 05:12:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5404A3947406 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 3D2E24020D9 for ; Tue, 22 Jun 2021 05:12:36 +0000 (UTC) Received: from pdx1-sub0-mail-a46.g.dreamhost.com (100-98-55-86.trex.outbound.svc.cluster.local [100.98.55.86]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id C91C0402361 for ; Tue, 22 Jun 2021 05:12:35 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a46.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.98.55.86 (trex/6.3.3); Tue, 22 Jun 2021 05:12:36 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Well-Made-Eyes: 37b8773359b340f2_1624338756036_3804424615 X-MC-Loop-Signature: 1624338756036:884436025 X-MC-Ingress-Time: 1624338756036 Received: from pdx1-sub0-mail-a46.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a46.g.dreamhost.com (Postfix) with ESMTP id 76922880B4 for ; Mon, 21 Jun 2021 22:12:35 -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-a46.g.dreamhost.com (Postfix) with ESMTPSA id 472CC7F50D for ; Mon, 21 Jun 2021 22:12:34 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a46 To: libc-alpha@sourceware.org Subject: [PATCH v2 6/6] Add NEWS item for gconv-modules.d change Date: Tue, 22 Jun 2021 10:42:02 +0530 Message-Id: <20210622051202.4155709-7-siddhesh@sourceware.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210622051202.4155709-1-siddhesh@sourceware.org> References: <20210622051202.4155709-1-siddhesh@sourceware.org> 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_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" --- NEWS | 8 ++++++++ 1 file changed, 8 insertions(+) Reviewed-by: DJ Delorie diff --git a/NEWS b/NEWS index 58cf1dab68..cadc40262f 100644 --- a/NEWS +++ b/NEWS @@ -39,6 +39,14 @@ Major new features: supported when LFS (_FILE_OFFSET_BITS=64) is also enabled. It is only enabled for Linux and the full support requires a minimum version of 5.1. +* The main gconv-modules file in glibc now contains only a small set of + essential converter modules and the rest have been moved into a supplementary + configuration file gconv-modules-extra.conf in the gconv-modules.d directory + in the same GCONV_PATH. Similarly, external converter modules directories + may have supplementary configuration files in a gconv-modules.d directory + with names ending with .conf to logically classify the converter modules in + that directory. + Deprecated and removed features, and other changes affecting compatibility: * The function pthread_mutex_consistent_np has been deprecated; programs