unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Philipp Stephani <p.stephani2@gmail.com>, 27871@debbugs.gnu.org
Cc: Philipp Stephani <phst@google.com>
Subject: bug#27871: [PATCH] Treat unreachable current directory as error
Date: Sat, 30 Sep 2017 17:00:06 -0700	[thread overview]
Message-ID: <ee0eb3f4-b077-e718-950c-0e452e1be99d@cs.ucla.edu> (raw)
In-Reply-To: <20170930185006.54096-1-phst@google.com>

[-- Attachment #1: Type: text/plain, Size: 469 bytes --]

Philipp Stephani wrote:

> +  if (!file_name_absolute_p (dir))

That doesn't look right here, since leading '~' counts as absolute to 
file_name_absolute_p, which is not what is wanted here.

> +      errno = ENOTCONN;

Why ENOTCONN? Shouldn't it be ENOENT? The failure has nothing to do with socket 
connections.

Also, I'd feel a bit better if we apply the workaround only to the function that 
has the problem.

How about the attached patch instead?

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-bug-with-unmounted-directory-on-GNU-Linux.patch --]
[-- Type: text/x-patch; name="0001-Fix-bug-with-unmounted-directory-on-GNU-Linux.patch", Size: 1077 bytes --]

From a1f839b0c60fb345944ee39626e8645402c1f060 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
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


  parent reply	other threads:[~2017-10-01  0:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-29 21:06 bug#27871: 26.0.50; Bad handling of unmounted directory Philipp
2017-09-23 10:19 ` Philipp Stephani
2017-09-23 10:39   ` Eli Zaretskii
2017-09-23 11:30     ` Andreas Schwab
2017-09-23 11:33       ` Philipp Stephani
2017-09-23 11:38         ` Eli Zaretskii
2017-09-23 11:41           ` Eli Zaretskii
2017-09-30 18:49             ` Philipp Stephani
2017-09-30 18:50               ` bug#27871: [PATCH] Treat unreachable current directory as error Philipp Stephani
     [not found]               ` <20170930185006.54096-1-phst@google.com>
2017-10-01  0:00                 ` Paul Eggert [this message]
2017-10-05 10:13                   ` Eli Zaretskii
2017-10-05 23:06                     ` Paul Eggert
2017-10-07  8:49                   ` Philipp Stephani
2017-10-08  6:04                     ` Paul Eggert
2017-10-08 14:56                       ` Philipp Stephani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ee0eb3f4-b077-e718-950c-0e452e1be99d@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=27871@debbugs.gnu.org \
    --cc=p.stephani2@gmail.com \
    --cc=phst@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).