changeset 100610:ee0ea39bc6a3

(Fexpand_file_name): Do not allow ../ to go beyond the server name in UNC paths.
author Jason Rumney <jasonr@gnu.org>
date Sat, 20 Dec 2008 15:17:28 +0000
parents 4f0bbd8c0ac6
children 32c5cd30347a
files src/fileio.c
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/fileio.c	Sat Dec 20 14:39:45 2008 +0000
+++ b/src/fileio.c	Sat Dec 20 15:17:28 2008 +0000
@@ -1323,8 +1323,18 @@
 #endif
 		 && (IS_DIRECTORY_SEP (p[3]) || p[3] == 0))
 	  {
+#ifdef WINDOWSNT
+	    unsigned char *prev_o = o;
+#endif
 	    while (o != target && (--o) && !IS_DIRECTORY_SEP (*o))
 	      ;
+#ifdef WINDOWSNT
+	    /* Don't go below server level in UNC filenames.  */
+	    if (o == target + 1 && IS_DIRECTORY_SEP (*o)
+		&& IS_DIRECTORY_SEP (*target))
+	      o = prev_o;
+	    else
+#endif
 	    /* Keep initial / only if this is the whole name.  */
 	    if (o == target && IS_ANY_SEP (*o) && p[3] == 0)
 	      ++o;