From f5321b5c8a5fe2e79344f79f790283ae3a13c2a8 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Sat, 16 May 1998 19:56:07 +0000 Subject: [PATCH] (Fexpand_file_name) [WINDOWSNT]: Be careful not to concatenate the directory prefix and file name to accidentally create a network share name. --- src/fileio.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/fileio.c b/src/fileio.c index 352129a0853..aef7a01e0a3 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -1419,7 +1419,18 @@ See also the function `substitute-in-file-name'.") { #ifndef VMS if (nm[0] == 0 || IS_DIRECTORY_SEP (nm[0])) - strcpy (target, newdir); + { +#ifdef WINDOWSNT + /* If newdir is effectively "C:/", then the drive letter will have + been stripped and newdir will be "/". Concatenating with an + absolute directory in nm produces "//", which will then be + incorrectly treated as a network share. Ignore newdir in + this case (keeping the drive letter). */ + if (!(drive && nm[0] && IS_DIRECTORY_SEP (newdir[0]) + && newdir[1] == '\0')) +#endif + strcpy (target, newdir); + } else #endif file_name_as_directory (target, newdir); -- 2.39.2