]> git.eshelyaron.com Git - emacs.git/commitdiff
Work around macOS faccessat bug
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 6 Feb 2018 00:27:24 +0000 (16:27 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 6 Feb 2018 00:28:41 +0000 (16:28 -0800)
* src/fileio.c (file_accessible_directory_p): Append an
extra "/" to work around macOS bug in faccessat (Bug#30350).

src/fileio.c

index be29e60fc0a6b97c54dba01d33cbeea976edecb9..b0ef3d4e91f8847af32bf2d25a45e240f76ac9a3 100644 (file)
@@ -2811,12 +2811,15 @@ file_accessible_directory_p (Lisp_Object file)
     dir = data;
   else
     {
-      /* Just check for trailing '/' when deciding whether to append '/'.
-        That's simpler than testing the two special cases "/" and "//",
-        and it's a safe optimization here.  */
-      char *buf = SAFE_ALLOCA (len + 3);
+      /* Just check for trailing '/' when deciding whether append '/'
+        before appending '.'.  That's simpler than testing the two
+        special cases "/" and "//", and it's a safe optimization
+        here.  After appending '.', append another '/' to work around
+        a macOS bug (Bug#30350).  */
+      static char const appended[] = "/./";
+      char *buf = SAFE_ALLOCA (len + sizeof appended);
       memcpy (buf, data, len);
-      strcpy (buf + len, &"/."[data[len - 1] == '/']);
+      strcpy (buf + len, &appended[data[len - 1] == '/']);
       dir = buf;
     }