From a1f839b0c60fb345944ee39626e8645402c1f060 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 30 Sep 2017 16:53:54 -0700 Subject: [PATCH] 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). --- src/sysdep.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/sysdep.c b/src/sysdep.c index 1e6e0d011b..a3526c3740 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; -- 2.13.5