stas Wed May 28 21:42:21 2008 UTC
Modified files: (Branch: PHP_5_3)
/php-src/ext/phar phar.c
Log:
Fix code path in phar_open_compiled_file() that tries
to open not-yet-loaded phar and fails on compressed files
# By Gregory's request
# Sorry, can't find how to write test case for that - it reproduces
# for me only under bytecode-caching. Suggestions welcome.
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar.c?r1=1.370.2.5&r2=1.370.2.6&diff_format=u
Index: php-src/ext/phar/phar.c
diff -u php-src/ext/phar/phar.c:1.370.2.5 php-src/ext/phar/phar.c:1.370.2.6
--- php-src/ext/phar/phar.c:1.370.2.5 Thu May 22 06:33:08 2008
+++ php-src/ext/phar/phar.c Wed May 28 21:42:21 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar.c,v 1.370.2.5 2008/05/22 06:33:08 cellog Exp $ */
+/* $Id: phar.c,v 1.370.2.6 2008/05/28 21:42:21 stas Exp $ */
#define PHAR_MAIN 1
#include "phar_internal.h"
@@ -1886,6 +1886,8 @@
zval *halt_constant;
php_stream *fp;
int fname_len;
+ char *actual = NULL;
+ int ret;
if (error) {
*error = NULL;
@@ -1915,16 +1917,38 @@
halt_offset = Z_LVAL(*halt_constant);
FREE_ZVAL(halt_constant);
- fp = php_stream_open_wrapper(fname, "rb",
IGNORE_URL|STREAM_MUST_SEEK|REPORT_ERRORS, NULL);
+#if PHP_MAJOR_VERSION < 6
+ if (PG(safe_mode) && (!php_checkuid(fname, NULL,
CHECKUID_ALLOW_ONLY_FILE))) {
+ return FAILURE;
+ }
+#endif
+
+ if (php_check_open_basedir(fname TSRMLS_CC)) {
+ return FAILURE;
+ }
+
+ fp = php_stream_open_wrapper(fname, "rb",
IGNORE_URL|STREAM_MUST_SEEK|REPORT_ERRORS, &actual);
if (!fp) {
- if (error) {
+ if (error) {
spprintf(error, 0, "unable to open phar for reading
\"%s\"", fname);
- }
+ }
+ if (actual) {
+ efree(actual);
+ }
return FAILURE;
- }
+ }
- return phar_open_file(fp, fname, fname_len, alias, alias_len,
halt_offset, NULL, PHAR_FILE_COMPRESSED_NONE, error TSRMLS_CC);
+ if (actual) {
+ fname = actual;
+ fname_len = strlen(actual);
+ }
+
+ ret = phar_open_fp(fp, fname, fname_len, alias, alias_len,
REPORT_ERRORS, NULL, error TSRMLS_CC);
+ if (actual) {
+ efree(actual);
+ }
+ return ret;
}
/* }}} */
@@ -3027,7 +3051,7 @@
php_info_print_table_header(2, "Phar: PHP Archive support", "enabled");
php_info_print_table_row(2, "Phar EXT version", PHP_PHAR_VERSION);
php_info_print_table_row(2, "Phar API version", PHP_PHAR_API_VERSION);
- php_info_print_table_row(2, "CVS revision", "$Revision: 1.370.2.5 $");
+ php_info_print_table_row(2, "CVS revision", "$Revision: 1.370.2.6 $");
php_info_print_table_row(2, "Phar-based phar archives", "enabled");
php_info_print_table_row(2, "Tar-based phar archives", "enabled");
php_info_print_table_row(2, "ZIP-based phar archives", "enabled");
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php