-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

My testing on rename found another corner case: we rejected
rename("dir","a/./") but accepted rename("dir","a/.//").  OK to commit?

For reference, the test I am writing for hammering rename() and renameat()
corner cases is currently visible here; it will be part of the next
coreutils release, among other places.  It currently stands at 400+ lines,
and exposes bugs in NetBSD, Solaris 10, mingw, and cygwin 1.5, but passes
on cygwin 1.7 (after this patch) and on Linux:
http://repo.or.cz/w/gnulib/ericb.git?a=blob;f=tests/test-rename.h

2009-09-30  Eric Blake  <e...@byu.net>

        * path.cc (has_dot_last_component): Detect "a/.//".

- --
Don't work too hard, make some time for fun as well!

Eric Blake             e...@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrDSgEACgkQ84KuGfSFAYDIHACgqgrcRJ0E9NuYHTsZpgopyDY7
+YMAnj0pA/eQ1DbHPNPn4dpg4ddoem4p
=3WS7
-----END PGP SIGNATURE-----
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index e543dd4..9f24f4f 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -207,11 +207,16 @@ has_dot_last_component (const char *dir, bool 
test_dot_dot)
   if (!last_comp)
     last_comp = dir;
   else {
-    /* Check for trailing slash.  If so, hop back to the previous slash. */
+    /* Check for trailing slashes.  If so, hop back to the previous slash. */
     if (!last_comp[1])
-      while (last_comp > dir)
-       if (*--last_comp == '/')
-         break;
+      {
+       while (last_comp > dir)
+         if (*--last_comp != '/')
+           break;
+       while (last_comp > dir)
+         if (*--last_comp == '/')
+           break;
+      }
     if (*last_comp == '/')
       ++last_comp;
   }

Reply via email to