diff options
Diffstat (limited to 'ext/sqlite/sqlite.c')
-rw-r--r-- | ext/sqlite/sqlite.c | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/ext/sqlite/sqlite.c b/ext/sqlite/sqlite.c index c499fa530c..b7a9483342 100644 --- a/ext/sqlite/sqlite.c +++ b/ext/sqlite/sqlite.c @@ -1237,13 +1237,13 @@ PHP_FUNCTION(sqlite_popen) 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))) { + if (!(fullpath = expand_filepath(filename, NULL TSRMLS_CC))) { RETURN_FALSE; } - if (php_check_open_basedir(fullpath TSRMLS_CC)) { + if ((PG(safe_mode) && (!php_checkuid(fullpath, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || + php_check_open_basedir(fullpath TSRMLS_CC)) { + efree(fullpath); RETURN_FALSE; } } else { @@ -1313,11 +1313,8 @@ PHP_FUNCTION(sqlite_open) 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))) { + if (!(fullpath = expand_filepath(filename, NULL TSRMLS_CC))) { php_std_error_handling(); - efree(fullpath); if (object) { RETURN_NULL(); } else { @@ -1325,7 +1322,8 @@ PHP_FUNCTION(sqlite_open) } } - if (php_check_open_basedir(fullpath TSRMLS_CC)) { + if ((PG(safe_mode) && (!php_checkuid(fullpath, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || + php_check_open_basedir(fullpath TSRMLS_CC)) { php_std_error_handling(); efree(fullpath); if (object) { @@ -1334,7 +1332,6 @@ PHP_FUNCTION(sqlite_open) RETURN_FALSE; } } - } php_sqlite_open(fullpath ? fullpath : filename, (int)mode, NULL, return_value, errmsg, object TSRMLS_CC); @@ -1368,15 +1365,13 @@ PHP_FUNCTION(sqlite_factory) 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))) { - efree(fullpath); + if (!(fullpath = expand_filepath(filename, NULL TSRMLS_CC))) { php_std_error_handling(); RETURN_NULL(); } - if (php_check_open_basedir(fullpath TSRMLS_CC)) { + if ((PG(safe_mode) && (!php_checkuid(fullpath, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || + php_check_open_basedir(fullpath TSRMLS_CC)) { efree(fullpath); php_std_error_handling(); RETURN_NULL(); |