]> Savannah Git Hosting - gnulib.git/commitdiff
access: Make last change work also when module 'stat' is in use.
authorBruno Haible <bruno@clisp.org>
Tue, 3 Oct 2023 15:59:38 +0000 (17:59 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 3 Oct 2023 16:00:57 +0000 (18:00 +0200)
* lib/access.c (access): When stat() returns -1 with errno != EOVERFLOW,
fail.

ChangeLog
lib/access.c

index 0c8d28f1139edbbbc9ad606a91ce18f2bb268121..9b4317264ed632bb587826737cfbd6eecd91df3a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2023-10-03  Bruno Haible  <bruno@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.
+
        access: Work around trailing slash bug on Mac OS X 10.5.
        * m4/access.m4 (gl_FUNC_ACCESS): Test whether access honors a trailing
        slash. Set REPLACE_ACCESS to 1 and define ACCESS_TRAILING_SLASH_BUG if
index 75d2148453c3c61f39e40914476e55878135b8ff..a7acf8c49eccae54fe4fbe04a72139d5f89f34fe 100644 (file)
@@ -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