MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Chuck Bell Date:October 15 2009 3:42pm
Subject:bzr commit into mysql-6.0-backup branch (charles.bell:2881) Bug#41843
View as plain text  
#At file:///Users/cbell/source/bzr/mysql-6.0-bug-41843/ based on revid:oystein.grovlen@stripped

 2881 Chuck Bell	2009-10-15
      BUG#41843 : Can not do backup to a named pipe on windows
      
      The system currently interprets '\\.\pipe\namedpipe' as a fixed
      path translated to 'pipe\namedpipe' which is not a valid
      named pipe on windows. The path in question is a valid 
      representation of '\\localhost\pipe\namedpipe' and therefore
      should be preserved.
      
      This patch preserves the path notation.
     @ mysys/mf_pack.c
        Preserve the \\.\ sequence in the path.
     @ unittest/mysys/safe_cleanup_cat_path-t.c
        Added unit test cases for paths that form a named pipe including
        a test for the specific failure described in the bug report.

    modified:
      mysys/mf_pack.c
      unittest/mysys/safe_cleanup_cat_path-t.c
=== modified file 'mysys/mf_pack.c'
--- a/mysys/mf_pack.c	2009-08-30 18:08:25 +0000
+++ b/mysys/mf_pack.c	2009-10-15 15:42:39 +0000
@@ -250,6 +250,7 @@ size_t cleanup_dirname(register char *to
   "/.." at end removes previous path element, if it is a real directory.
   "~/" at path begin replaces ~ by home directory.
   "//" is replaced by "/", except on Win32 at begin.
+  "\\.\" is preserved for use on Windows for named pipes.
 
   If the cleanup process would end up with an empty path, "." is
   returned.
@@ -305,6 +306,7 @@ size_t safe_cleanup_cat_path(char *to, s
   char   *start;
   char   *pos;
   char   *end;
+  my_bool non_exist_found= FALSE;
   char   parent[5];     /* for "FN_PARENTDIR" */
   DBUG_ENTER("safe_cleanup_cat_path");
 
@@ -455,10 +457,22 @@ size_t safe_cleanup_cat_path(char *to, s
 #endif
           pos--;
       }
-      /* Skip /./ which could also be at path end. */
-      else if (((pos - start) > 1) &&
-               (pos[-1] == FN_CURLIB) &&
-               (pos[-2] == FN_LIBCHAR))
+      /*
+        Skip /./ which could also be at path end.
+        If no non existent path elemnt has been found yet,
+        skip ./ This can happen after a leading ../
+        In Windows case leave //./ in the path intact.
+      */
+      else if (((((pos - start) > 1) &&
+                 (pos[-1] == FN_CURLIB) &&
+                 (pos[-2] == FN_LIBCHAR)) ||
+                (!non_exist_found &&
+                 ((pos - start) > 0) &&
+                 (pos[-1] == FN_CURLIB)))
+#ifdef FN_NETWORK_DRIVES
+                && !(((pos - to) == 3) && (pos[-3] == FN_LIBCHAR))
+#endif
+               )
       {
         pos-= 2; /* purecov: tested */ /* unittest */
       }
@@ -482,6 +496,7 @@ size_t safe_cleanup_cat_path(char *to, s
           {
             /* Prevent backstep over non-real-directory. */
             start= pos + 1;
+            non_exist_found= TRUE;
           }
         }
 #endif

=== modified file 'unittest/mysys/safe_cleanup_cat_path-t.c'
--- a/unittest/mysys/safe_cleanup_cat_path-t.c	2009-05-19 09:48:45 +0000
+++ b/unittest/mysys/safe_cleanup_cat_path-t.c	2009-10-15 15:42:39 +0000
@@ -153,7 +153,7 @@ main(void)
 
   /* Use "file" for a non-existent file. */
 
-  plan(65);
+  plan(70);
 
   do_test("", "");
 
@@ -166,9 +166,16 @@ main(void)
   do_test("///", "/");
   do_test("/file", "/file");
 #ifdef FN_NETWORK_DRIVES
+  do_test("//node/pipe/file///", "//node/pipe/file");
+  do_test("//node/file///", "//node/file");
+  do_test("//./pipe/file", "//./pipe/file");
+  do_test("//./file///", "//./file");
   do_test("//file///", "//file");
   do_test("///file///", "//file");
 #else
+  do_test("//dir1/dir2/file///", "/dir1/dir2/file");
+  do_test("//dir/file///", "/dir/file");
+  do_test("//./file///", "/file");
   do_test("//file///", "/file");
   do_test("///file///", "/file");
 #endif
@@ -224,6 +231,9 @@ main(void)
   do_test("dir1/dir2/..", "dir1");
   do_test("dir1/..", ".");
 
+  do_test(".././file///", "../file");
+  do_test("..///./file///", "../file");
+
 #if defined(__WIN__)
   /* Windows does path cleanup differently. */
   do_test("file/../file", "file");


Attachment: [text/bzr-bundle] bzr/charles.bell@sun.com-20091015154239-zboe2on7hmx3wuwb.bundle
Thread
bzr commit into mysql-6.0-backup branch (charles.bell:2881) Bug#41843Chuck Bell15 Oct