Check-in [d0d4c5f575]
Not logged in
Overview

SHA1 Hash:d0d4c5f5753e7c82049658c5fa1992f057fd895b
Date: 2007-07-28 08:15:54
User: dan
Comment:Fix to the db_open_local() function in the case where the root directory is writable by the current user.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/db.c from [fcfc75c8b2] to [3ac17e30e1].

@@ -527,23 +527,26 @@
   if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
     db_err("pwd too big: max %d", sizeof(zPwd)-20);
   }
   n = strlen(zPwd);
   while( n>0 ){
-    if( access(zPwd, W_OK) ) return 0;
+    if( access(zPwd, W_OK) ) break;
     strcpy(&zPwd[n], "/_FOSSIL_");
     if( isValidLocalDb(zPwd) ){
+      /* Found a valid _FOSSIL_ file */
       zPwd[n] = 0;
       g.zLocalRoot = mprintf("%s/", zPwd);
-      break;
+      return 1;
     }
     n--;
     while( n>0 && zPwd[n]!='/' ){ n--; }
     while( n>0 && zPwd[n-1]=='/' ){ n--; }
     zPwd[n] = 0;
   }
-  return 1;
+
+  /* A _FOSSIL_ file could not be found */
+  return 0;
 }
 
 /*
 ** Open the repository database given by zDbName.  If zDbName==NULL then
 ** get the name from the already open local database.