summaryrefslogtreecommitdiff
path: root/src/sysdep.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2017-10-05 15:55:10 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2017-10-05 16:05:49 -0700
commitdb893ab863770ef3f89102d6837cd3eb021429ba (patch)
treee745aa6bb412d8580c7e2fabe10a2bdafe14370b /src/sysdep.c
parent16dc580aa61832285269f8de081248bac618cf84 (diff)
downloademacs-db893ab863770ef3f89102d6837cd3eb021429ba.tar.gz
Fix bug with unmounted directory on GNU/Linux
* src/sysdep.c (emacs_get_current_dir_name): Do not use get_current_dir_name result unless it is absolute (Bug#27871).
Diffstat (limited to 'src/sysdep.c')
-rw-r--r--src/sysdep.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/sysdep.c b/src/sysdep.c
index 26d381f5796..8291a606bea 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -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;