I did:
> 2023-10-03  Bruno Haible  <br...@clisp.org>
> 
>       access: Work around trailing slash bug on Mac OS X 10.5.

This change was incomplete: When the 'stat' module is in use, the
unit test fails. Easy to fix:


2023-10-03  Bruno Haible  <br...@clisp.org>

        access: Make last change work also when module 'stat' is in use.
        * lib/access.c (access): When stat() returns -1 with errno != EOVERFLOW,
        fail.

diff --git a/lib/access.c b/lib/access.c
index 75d2148453..a7acf8c49e 100644
--- a/lib/access.c
+++ b/lib/access.c
@@ -52,11 +52,16 @@ access (const char *file, int mode)
       if (file_len > 0 && file[file_len - 1] == '/')
         {
           struct stat st;
-          if (stat (file, &st) == 0 && ! S_ISDIR (st.st_mode))
+          if (stat (file, &st) == 0)
             {
-              errno = ENOTDIR;
-              return -1;
+              if (! S_ISDIR (st.st_mode))
+                {
+                  errno = ENOTDIR;
+                  return -1;
+                }
             }
+          else
+            return (mode == F_OK && errno == EOVERFLOW ? 0 : -1);
         }
     }
 # endif




Reply via email to