iliaa Sat Mar 6 13:14:55 2004 EDT Modified files: /php-src/ext/sqlite sqlite.c Log: Fixed a possible memory leaks inside sqlite_popen() & sqlite_fetch_column_types(). Resolve the file path inside sqlite_factory(). http://cvs.php.net/diff.php/php-src/ext/sqlite/sqlite.c?r1=1.126&r2=1.127&ty=u Index: php-src/ext/sqlite/sqlite.c diff -u php-src/ext/sqlite/sqlite.c:1.126 php-src/ext/sqlite/sqlite.c:1.127 --- php-src/ext/sqlite/sqlite.c:1.126 Thu Feb 26 19:29:09 2004 +++ php-src/ext/sqlite/sqlite.c Sat Mar 6 13:14:54 2004 @@ -17,7 +17,7 @@ | Marcus Boerger <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ - $Id: sqlite.c,v 1.126 2004/02/27 00:29:09 iliaa Exp $ + $Id: sqlite.c,v 1.127 2004/03/06 18:14:54 iliaa Exp $ */ #ifdef HAVE_CONFIG_H @@ -1054,7 +1054,7 @@ { php_info_print_table_start(); php_info_print_table_header(2, "SQLite support", "enabled"); - php_info_print_table_row(2, "PECL Module version", PHP_SQLITE_MODULE_VERSION " $Id: sqlite.c,v 1.126 2004/02/27 00:29:09 iliaa Exp $"); + php_info_print_table_row(2, "PECL Module version", PHP_SQLITE_MODULE_VERSION " $Id: sqlite.c,v 1.127 2004/03/06 18:14:54 iliaa Exp $"); php_info_print_table_row(2, "SQLite Library", sqlite_libversion()); php_info_print_table_row(2, "SQLite Encoding", sqlite_libencoding()); php_info_print_table_end(); @@ -1192,18 +1192,17 @@ } /* all set */ - efree(fullpath); - efree(hashkey); - return; + goto done; } php_error_docref(NULL TSRMLS_CC, E_WARNING, "Some other type of persistent resource is using this hash key!?"); - RETURN_FALSE; + RETVAL_FALSE; + goto done; } /* now we need to open the database */ php_sqlite_open(fullpath, (int)mode, hashkey, return_value, errmsg, NULL TSRMLS_CC); - +done: efree(fullpath); efree(hashkey); } @@ -1252,6 +1251,7 @@ RETURN_FALSE; } } + } php_sqlite_open(fullpath ? fullpath : filename, (int)mode, NULL, return_value, errmsg, object TSRMLS_CC); @@ -1268,7 +1268,7 @@ PHP_FUNCTION(sqlite_factory) { long mode = 0666; - char *filename; + char *filename, *fullname = NULL; long filename_len; zval *errmsg = NULL; @@ -1283,19 +1283,26 @@ } 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))) { + efree(fullpath); php_std_error_handling(); RETURN_NULL(); } - if (php_check_open_basedir(filename TSRMLS_CC)) { + if (php_check_open_basedir(fullpath TSRMLS_CC)) { + efree(fullpath); php_std_error_handling(); RETURN_NULL(); } } - php_sqlite_open(filename, (int)mode, NULL, return_value, errmsg, return_value TSRMLS_CC); - + php_sqlite_open(fullpath ? fullpath : filename, (int)mode, NULL, return_value, errmsg, return_value TSRMLS_CC); + if (fullpath) { + efree(fullpath); + } php_std_error_handling(); } /* }}} */ @@ -1575,7 +1582,7 @@ RETURN_FALSE; } - sqlite_exec(db->db, "PRAGMA show_datatypes = ON", NULL, NULL, &errtext); + sqlite_exec(db->db, "PRAGMA show_datatypes = ON", NULL, NULL, NULL); db->last_err_code = sqlite_compile(db->db, sql, &tail, &res.vm, &errtext); @@ -1605,7 +1612,7 @@ } done: - sqlite_exec(db->db, "PRAGMA show_datatypes = OFF", NULL, NULL, &errtext); + sqlite_exec(db->db, "PRAGMA show_datatypes = OFF", NULL, NULL, NULL); } /* }}} */
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php