]> granicus.if.org Git - php/commitdiff
Do not perform safe_mode & open_basedir checks for memory-only databases.
authorIlia Alshanetsky <iliaa@php.net>
Mon, 9 Jun 2003 20:36:55 +0000 (20:36 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 9 Jun 2003 20:36:55 +0000 (20:36 +0000)
ext/sqlite/sqlite.c

index 40e71c8298e203a26b802a8da9ae11a15afd4ca0..84d5307aaac34e21309bd1b117d2e8ab3bf11797 100644 (file)
@@ -733,15 +733,19 @@ PHP_FUNCTION(sqlite_popen)
                return;
        }
 
-       /* resolve the fully-qualified path name to use as the hash key */
-       fullpath = expand_filepath(filename, NULL TSRMLS_CC);
+       if (strncmp(filename, ":memory:", sizeof(":memory:") - 1)) {
+               /* resolve the fully-qualified path name to use as the hash key */
+               fullpath = expand_filepath(filename, NULL TSRMLS_CC);
        
-       if (PG(safe_mode) && (!php_checkuid(fullpath, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
-               RETURN_FALSE;
-       }
+               if (PG(safe_mode) && (!php_checkuid(fullpath, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
+                       RETURN_FALSE;
+               }
 
-       if (php_check_open_basedir(fullpath TSRMLS_CC)) {
-               RETURN_FALSE;
+               if (php_check_open_basedir(fullpath TSRMLS_CC)) {
+                       RETURN_FALSE;
+               }
+       } else {
+               fullpath = estrndup(filename, filename_len);
        }
 
        hashkeylen = spprintf(&hashkey, 0, "sqlite_pdb_%s:%d", fullpath, mode);
@@ -791,12 +795,14 @@ PHP_FUNCTION(sqlite_open)
                return;
        }
 
-       if (PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
-               RETURN_FALSE;
-       }
+       if (strncmp(filename, ":memory:", sizeof(":memory:") - 1)) {
+               if (PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
+                       RETURN_FALSE;
+               }
 
-       if (php_check_open_basedir(filename TSRMLS_CC)) {
-               RETURN_FALSE;
+               if (php_check_open_basedir(filename TSRMLS_CC)) {
+                       RETURN_FALSE;
+               }
        }
        
        php_sqlite_open(filename, mode, NULL, return_value, errmsg TSRMLS_CC);