On 10/ 3/18 03:15 PM, Roland Mainz wrote:
On Wed, Oct 3, 2018 at 11:51 PM Alan Coopersmith
<alan.coopersm...@oracle.com> wrote:

Introduced-by: commit 04bdbbcab3c4862bf3f54ce60fcc1d2007776f80
Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com>
---
  src/util/xmlconfig.c | 8 ++++++++
  1 file changed, 8 insertions(+)

diff --git a/src/util/xmlconfig.c b/src/util/xmlconfig.c
index 5264f2598b..608972f812 100644
--- a/src/util/xmlconfig.c
+++ b/src/util/xmlconfig.c
@@ -938,8 +938,16 @@ parseOneConfigFile(struct OptConfData *data, const char 
*filename)
  static int
  scandir_filter(const struct dirent *ent)
  {
+#ifndef DT_REG /* systems without d_type in dirent results */
+    struct stat st;
+
+    lstat(ent->d_name, &st);
+    if (!S_ISREG(st.st_mode) && !S_ISLNK(st.st_mode))
+       return 0;
+#else

What about testing for the return code of |lstat()|&&|errno| before
looking at the value of |st| ?

Oh, I suppose there is a small window in which the file could disappear after it's read from the directory entry, but before the lstat occurs.

Attached version checks for that.

--
        -Alan Coopersmith-               alan.coopersm...@oracle.com
         Oracle Solaris Engineering - https://blogs.oracle.com/alanc
>From 21e491c1f0f112ccdf3df1ad8f1d1722fe272fd6 Mon Sep 17 00:00:00 2001
From: Alan Coopersmith <alan.coopersm...@oracle.com>
Date: Tue, 2 Oct 2018 22:04:04 -0700
Subject: [PATCH:mesa] util: Make xmlconfig.c build on Solaris without d_type
 in dirent (v2)

v2: check for lstat() failing

Introduced-by: commit 04bdbbcab3c4862bf3f54ce60fcc1d2007776f80
Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com>
---
 src/util/xmlconfig.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/util/xmlconfig.c b/src/util/xmlconfig.c
index 5264f2598b..5907c68012 100644
--- a/src/util/xmlconfig.c
+++ b/src/util/xmlconfig.c
@@ -938,8 +938,16 @@ parseOneConfigFile(struct OptConfData *data, const char *filename)
 static int
 scandir_filter(const struct dirent *ent)
 {
+#ifndef DT_REG /* systems without d_type in dirent results */
+    struct stat st;
+
+    if ((lstat(ent->d_name, &st) != 0) ||
+        (!S_ISREG(st.st_mode) && !S_ISLNK(st.st_mode)))
+       return 0;
+#else
     if (ent->d_type != DT_REG && ent->d_type != DT_LNK)
        return 0;
+#endif
 
     if (fnmatch("*.conf", ent->d_name, 0))
        return 0;
-- 
2.15.2

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to