From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from hamster.birch.relay.mailchannels.net (hamster.birch.relay.mailchannels.net [23.83.209.80]) by sourceware.org (Postfix) with ESMTPS id 11664385E449 for ; Wed, 9 Jun 2021 04:38:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 11664385E449 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 AE5109227EA; Wed, 9 Jun 2021 04:38:50 +0000 (UTC) Received: from pdx1-sub0-mail-a10.g.dreamhost.com (100-96-16-76.trex.outbound.svc.cluster.local [100.96.16.76]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 0E2F6922665; Wed, 9 Jun 2021 04:38:50 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a10.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.96.16.76 (trex/6.3.1); Wed, 09 Jun 2021 04:38:50 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Madly-Whistle: 55751c347100f673_1623213530354_476362944 X-MC-Loop-Signature: 1623213530354:2965510645 X-MC-Ingress-Time: 1623213530354 Received: from pdx1-sub0-mail-a10.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a10.g.dreamhost.com (Postfix) with ESMTP id BC1927EFCF; Tue, 8 Jun 2021 21:38:49 -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-a10.g.dreamhost.com (Postfix) with ESMTPSA id 036907EFCE; Tue, 8 Jun 2021 21:38:45 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a10 From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Cc: dj@redhat.com, schwab@linux-m68k.org Subject: [PATCH] Handle DT_UNKNOWN in gconv-modules.d Date: Wed, 9 Jun 2021 10:08:35 +0530 Message-Id: <20210609043835.218509-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.7 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-List-Received-Date: Wed, 09 Jun 2021 04:38:53 -0000 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. --- iconv/gconv_conf.c | 9 ++++++++- iconv/iconvconfig.c | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c index c8ad8099a4..7fc3a810af 100644 --- a/iconv/gconv_conf.c +++ b/iconv/gconv_conf.c @@ -587,7 +587,7 @@ __gconv_read_conf (void) struct dirent *ent; while ((ent =3D __readdir (confdir)) !=3D NULL) { - if (ent->d_type !=3D DT_REG) + if (ent->d_type !=3D DT_REG && ent->d_type !=3D DT_UNKNOWN) continue; =20 size_t len =3D strlen (ent->d_name); @@ -596,10 +596,17 @@ __gconv_read_conf (void) if (len > strlen (suffix) && strcmp (ent->d_name + len - strlen (suffix), suffix) =3D=3D 0) { + struct stat64 st; /* LEN <=3D PATH_MAX so this alloca is not unbounded. */ char *conf =3D alloca (BUF_LEN + len + 1); cp =3D stpcpy (conf, buf); sprintf (cp, "/%s", ent->d_name); + + if (ent->d_type =3D=3D DT_UNKNOWN + && (__lstat64 (conf, &st) =3D=3D -1 + || !S_ISREG (st.st_mode))) + continue; + read_conf_file (conf, elem, elem_len, &modules, &nmodules); } } diff --git a/iconv/iconvconfig.c b/iconv/iconvconfig.c index b2a868919c..8f10f4aba8 100644 --- a/iconv/iconvconfig.c +++ b/iconv/iconvconfig.c @@ -747,7 +747,7 @@ handle_dir (const char *dir) struct dirent *ent; while ((ent =3D readdir (confdir)) !=3D NULL) { - if (ent->d_type !=3D DT_REG) + if (ent->d_type !=3D DT_REG && ent->d_type !=3D DT_UNKNOWN) continue; =20 size_t len =3D strlen (ent->d_name); @@ -756,10 +756,16 @@ handle_dir (const char *dir) if (len > strlen (suffix) && strcmp (ent->d_name + len - strlen (suffix), suffix) =3D=3D 0) { + struct stat64 st; /* LEN <=3D PATH_MAX so this alloca is not unbounded. */ char *conf =3D alloca (BUF_LEN + len + 1); cp =3D stpcpy (conf, buf); sprintf (cp, "/%s", ent->d_name); + + if (ent->d_type =3D=3D DT_UNKNOWN + && (lstat64 (conf, &st) =3D=3D -1 || !S_ISREG (st.st_mode))) + continue; + found |=3D handle_file (dir, conf); } } --=20 2.31.1