]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bug with unmounted directory on GNU/Linux
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 5 Oct 2017 22:55:10 +0000 (15:55 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 5 Oct 2017 23:05:49 +0000 (16:05 -0700)
* src/sysdep.c (emacs_get_current_dir_name): Do not use
get_current_dir_name result unless it is absolute (Bug#27871).

src/sysdep.c

index 26d381f5796ab31c37a9bee4da3e56ecb413ab82..8291a606bea1e21cee2274b7424a8101d5f6cd16 100644 (file)
@@ -232,7 +232,18 @@ emacs_get_current_dir_name (void)
   bool use_libc = true;
 #  endif
   if (use_libc)
-    return get_current_dir_name ();
+    {
+      /* GNU/Linux get_current_dir_name can return a string starting
+        with "(unreachable)" (Bug#27871).  */
+      char *wd = get_current_dir_name ();
+      if (wd && ! (IS_DIRECTORY_SEP (*wd) || (*wd && IS_DEVICE_SEP (wd[1]))))
+       {
+         free (wd);
+         errno = ENOENT;
+         return NULL;
+       }
+      return wd;
+    }
 # endif
 
   char *buf;