From: Paul Eggert Date: Thu, 5 Oct 2017 22:55:10 +0000 (-0700) Subject: Fix bug with unmounted directory on GNU/Linux X-Git-Tag: emacs-26.0.90~45^2~19 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=db893ab863770ef3f89102d6837cd3eb021429ba;p=emacs.git 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). --- 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;