GNU bug report logs - #27871
26.0.50; Bad handling of unmounted directory

Previous Next

Package: emacs;

Reported by: Philipp <p.stephani2 <at> gmail.com>

Date: Sat, 29 Jul 2017 21:08:02 UTC

Severity: minor

Found in version 26.0.50

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #17 received at 27871 <at> debbugs.gnu.org (full text, mbox):

From: Philipp Stephani <p.stephani2 <at> gmail.com>
To: Andreas Schwab <schwab <at> linux-m68k.org>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 27871 <at> debbugs.gnu.org
Subject: Re: bug#27871: 26.0.50; Bad handling of unmounted directory
Date: Sat, 23 Sep 2017 11:33:13 +0000
[Message part 1 (text/plain, inline)]
Andreas Schwab <schwab <at> linux-m68k.org> schrieb am Sa., 23. Sep. 2017 um
13:30 Uhr:

> On Sep 23 2017, Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> >> +/* Return the current working directory.  The result should be freed
> >> +   with 'free'.  Return NULL on errors.  */
> >> +char *
> >> +emacs_get_current_dir_name (void)
> >> +{
> >> +  char *dir = emacs_get_current_dir_name_1 ();
> >> +  if (dir == NULL)
> >> +    return NULL;
> >> +  /* On Linux, getcwd and get_current_dir_name return a string
> >> +     starting with "(unreachable)" if the current directory doesn't
> >> +     exist, e.g. because it was unmounted.  Treat that as an error.
> >> +     See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27871.  */
> >> +  const char *prefix = "(unreachable)";
> >> +  size_t dir_len = strlen (dir);
> >> +  size_t prefix_len = strlen (prefix);
> >> +  if (dir_len >= prefix_len && strncmp (dir, prefix, prefix_len) == 0)
> >> +    {
> >> +      errno = ENOTCONN;
> >> +      return NULL;
> >
> > What if there's a directory called literally "(unreachable)SOMETHING"?
>
> An absolute file name cannot start with "(unreachable)".
>
>
Yes, and getcwd and friends only return absolute filenames, and we only use
$PWD if it's absolute, so anything except '/' or a drive letter can't be a
prefix in the success case. I'll add a comment to that effect.
[Message part 2 (text/html, inline)]

This bug report was last modified 7 years and 233 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.