bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#27871: 26.0.50; Bad handling of unmounted directory


From: Andreas Schwab
Subject: bug#27871: 26.0.50; Bad handling of unmounted directory
Date: Sat, 23 Sep 2017 13:30:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)

On Sep 23 2017, Eli Zaretskii <address@hidden> 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)".

Andreas.

-- 
Andreas Schwab, address@hidden
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."





reply via email to

[Prev in Thread] Current Thread [Next in Thread]