public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Siddhesh Poyarekar <siddhesh@sourceware.org>
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	[thread overview]
Message-ID: <20210609043835.218509-1-siddhesh@sourceware.org> (raw)

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 = __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);
@@ -596,10 +596,17 @@ __gconv_read_conf (void)
 	      if (len > strlen (suffix)
 		  && strcmp (ent->d_name + len - strlen (suffix), suffix) == 0)
 		{
+		  struct stat64 st;
 		  /* 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);
+
+		  if (ent->d_type == DT_UNKNOWN
+		      && (__lstat64 (conf, &st) == -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 = 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);
@@ -756,10 +756,16 @@ handle_dir (const char *dir)
 	  if (len > strlen (suffix)
 	      && strcmp (ent->d_name + len - strlen (suffix), suffix) == 0)
 	    {
+	      struct stat64 st;
 	      /* 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);
+
+	      if (ent->d_type == DT_UNKNOWN
+		  && (lstat64 (conf, &st) == -1 || !S_ISREG (st.st_mode)))
+		continue;
+
 	      found |= handle_file (dir, conf);
 	    }
 	}
-- 
2.31.1


             reply	other threads:[~2021-06-09  4:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-09  4:38 Siddhesh Poyarekar [this message]
2021-06-09 17:21 ` Adhemerval Zanella
2021-06-09 18:08   ` Siddhesh Poyarekar
2021-06-09 18:27     ` Florian Weimer
2021-06-09 18:28       ` Siddhesh Poyarekar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210609043835.218509-1-siddhesh@sourceware.org \
    --to=siddhesh@sourceware.org \
    --cc=dj@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).