apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject svn commit: r291341 - in /apr/apr/branches/0.9.x: CHANGES file_io/unix/dir.c test/testdir.c
Date Sat, 24 Sep 2005 22:27:25 GMT
Author: jorton
Date: Sat Sep 24 15:27:18 2005
New Revision: 291341

URL: http://svn.apache.org/viewcvs?rev=291341&view=rev
Log:
Merge r291339 from trunk:

* file_io/unix/dir.c (apr_dir_make_recursive): Fix infinite recursion
if mkdir fails for all path components.

* test/testdir.c (test_rmkdir_nocwd): Add test case.

Modified:
    apr/apr/branches/0.9.x/CHANGES
    apr/apr/branches/0.9.x/file_io/unix/dir.c
    apr/apr/branches/0.9.x/test/testdir.c

Modified: apr/apr/branches/0.9.x/CHANGES
URL: http://svn.apache.org/viewcvs/apr/apr/branches/0.9.x/CHANGES?rev=291341&r1=291340&r2=291341&view=diff
==============================================================================
--- apr/apr/branches/0.9.x/CHANGES (original)
+++ apr/apr/branches/0.9.x/CHANGES Sat Sep 24 15:27:18 2005
@@ -1,5 +1,8 @@
 Changes with APR 0.9.7
 
+  *) Fix crash in apr_dir_make_recursive() for relative path
+     when the working directory has been deleted.  [Joe Orton]
+
   *) Win32: fix apr_proc_mutex_trylock() to handle WAIT_TIMEOUT,
      returning APR_EBUSY.  [Ronen Mizrahi <ronen@tversity.com>]
 

Modified: apr/apr/branches/0.9.x/file_io/unix/dir.c
URL: http://svn.apache.org/viewcvs/apr/apr/branches/0.9.x/file_io/unix/dir.c?rev=291341&r1=291340&r2=291341&view=diff
==============================================================================
--- apr/apr/branches/0.9.x/file_io/unix/dir.c (original)
+++ apr/apr/branches/0.9.x/file_io/unix/dir.c Sat Sep 24 15:27:18 2005
@@ -276,6 +276,11 @@
         char *dir;
         
         dir = path_remove_last_component(path, pool);
+        /* If there is no path left, give up. */
+        if (dir[0] == '\0') {
+            return apr_err;
+        }
+
         apr_err = apr_dir_make_recursive(dir, perm, pool);
         
         if (!apr_err) 

Modified: apr/apr/branches/0.9.x/test/testdir.c
URL: http://svn.apache.org/viewcvs/apr/apr/branches/0.9.x/test/testdir.c?rev=291341&r1=291340&r2=291341&view=diff
==============================================================================
--- apr/apr/branches/0.9.x/test/testdir.c (original)
+++ apr/apr/branches/0.9.x/test/testdir.c Sat Sep 24 15:27:18 2005
@@ -219,6 +219,29 @@
 
 }
 
+static void test_rmkdir_nocwd(CuTest *tc)
+{
+    char *cwd, *path;
+
+    apr_assert_success(tc, "make temp dir",
+                       apr_dir_make("dir3", APR_OS_DEFAULT, p));
+
+    apr_assert_success(tc, "obtain cwd", apr_filepath_get(&cwd, 0, p));
+
+    apr_assert_success(tc, "determine path to temp dir",
+                       apr_filepath_merge(&path, cwd, "dir3", 0, p));
+
+    apr_assert_success(tc, "change to temp dir", apr_filepath_set(path, p));
+
+    apr_assert_success(tc, "remove temp dir", apr_dir_remove(path, p));
+
+    CuAssert(tc, "fail to create dir",
+             apr_dir_make_recursive("foobar", APR_OS_DEFAULT, 
+                                    p) != APR_SUCCESS);
+
+    apr_assert_success(tc, "restore cwd", apr_filepath_set(cwd, p));
+}
+
 CuSuite *testdir(void)
 {
     CuSuite *suite = CuSuiteNew("Directory");
@@ -230,6 +253,7 @@
     SUITE_ADD_TEST(suite, test_removeall);
     SUITE_ADD_TEST(suite, test_remove_notthere);
     SUITE_ADD_TEST(suite, test_mkdir_twice);
+    SUITE_ADD_TEST(suite, test_rmkdir_nocwd);
 
     SUITE_ADD_TEST(suite, test_rewind);
 



Mime
View raw message