PHP_FUNCTION(sqlite_open)
{
int mode = 0666;
- char *filename;
+ char *filename, *fullpath = NULL;
long filename_len;
zval *errmsg = NULL;
zval *object = getThis();
}
if (strncmp(filename, ":memory:", sizeof(":memory:") - 1)) {
- if (PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
+ /* 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))) {
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
+ efree(fullpath);
if (object) {
RETURN_NULL();
} else {
RETURN_FALSE;
}
}
-
- if (php_check_open_basedir(filename TSRMLS_CC)) {
+
+ if (php_check_open_basedir(fullpath TSRMLS_CC)) {
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
+ efree(fullpath);
if (object) {
RETURN_NULL();
} else {
}
}
- php_sqlite_open(filename, mode, NULL, return_value, errmsg, object TSRMLS_CC);
+ php_sqlite_open(fullpath?fullpath:filename, mode, NULL, return_value, errmsg, object TSRMLS_CC);
+ if (fullpath) {
+ efree(fullpath);
+ }
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
}
/* }}} */