This is the mail archive of the cygwin-patches@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch]: chdir


"Pierre A. Humblet" wrote:
> 
> Corinna Vinschen wrote:
> > Ooops:
> >
> >   $ cd /
> >   /: No such file or directory.
> 
> Oops, nothing to do with chdir. It's in the code that detects
> file components consisting entirely of dots or spaces.

And here is the corrected patch.

Pierre

2004-05-06  Pierre Humblet <pierre.humblet@ieee.org>

	* path.cc (path_conv::check): Strip trailing dots and spaces and returns
	error if the final component had only dots and spaces.
	(normalize_posix_path): Revert 2004-04-30.
Index: path.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/path.cc,v
retrieving revision 1.308
diff -u -p -r1.308 path.cc
--- path.cc	4 May 2004 15:14:48 -0000	1.308
+++ path.cc	6 May 2004 14:47:11 -0000
@@ -286,10 +286,6 @@ normalize_posix_path (const char *src, c
     }
 
 done:
-  /* Remove trailing dots and spaces which are ignored by Win32 functions but
-     not by native NT functions. */
-  while (dst[-1] == '.' || dst[-1] == ' ')
-    --dst;
   *dst = '\0';
   *tail = dst;
 
@@ -552,12 +548,25 @@ path_conv::check (const char *src, unsig
       /* Detect if the user was looking for a directory.  We have to strip the
 	 trailing slash initially while trying to add extensions but take it
 	 into account during processing */
-      if (tail > path_copy + 1 && isslash (*(tail - 1)))
+      if (tail > path_copy + 1)
 	{
-	  need_directory = 1;
-	  *--tail = '\0';
-	}
+          if (isslash (tail[-1]))
+            {
+	       need_directory = 1;
+	       tail--;
+	    }
+          /* Remove trailing dots and spaces which are ignored by Win32 functions but
+	     not by native NT functions. */
+          while (tail[-1] == '.' || tail[-1] == ' ') 
+	    tail--;
+          if (isslash (tail[-1]))
+            {
+	      error = ENOENT;
+              return;
+	    }
+        }
       path_end = tail;
+      *tail = '\0';
 
       /* Scan path_copy from right to left looking either for a symlink
 	 or an actual existing file.  If an existing file is found, just

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]