From d3ad6e640da41951f6cf13d30d3238b1e1589e1f Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Mon, 9 Jun 2003 20:36:55 +0000 Subject: Do not perform safe_mode & open_basedir checks for memory-only databases. --- ext/sqlite/sqlite.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'ext/sqlite/sqlite.c') diff --git a/ext/sqlite/sqlite.c b/ext/sqlite/sqlite.c index 40e71c8298..84d5307aaa 100644 --- a/ext/sqlite/sqlite.c +++ b/ext/sqlite/sqlite.c @@ -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); -- cgit v1.2.1