cellog Wed May 13 20:26:18 2009 UTC
Modified files:
/php-src/ext/phar phar.c phar_internal.h tar.c
/php-src/ext/phar/tests/tar require_hash.phpt
/php-src/ext/phar/tests/tar/files Net_URL-1.0.15.tgz
Log:
MFB: fix Bug #48257: PharData throws exception with non-phar tar
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar.c?r1=1.399&r2=1.400&diff_format=u
Index: php-src/ext/phar/phar.c
diff -u php-src/ext/phar/phar.c:1.399 php-src/ext/phar/phar.c:1.400
--- php-src/ext/phar/phar.c:1.399 Fri May 1 09:22:02 2009
+++ php-src/ext/phar/phar.c Wed May 13 20:26:18 2009
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar.c,v 1.399 2009/05/01 09:22:02 tony2001 Exp $ */
+/* $Id: phar.c,v 1.400 2009/05/13 20:26:18 cellog Exp $ */
#define PHAR_MAIN 1
#include "phar_internal.h"
@@ -1345,7 +1345,7 @@
}
if (fp) {
- if (phar_open_from_fp(fp, fname, fname_len, alias, alias_len,
options, pphar, error TSRMLS_CC) == SUCCESS) {
+ if (phar_open_from_fp(fp, fname, fname_len, alias, alias_len,
options, pphar, is_data, error TSRMLS_CC) == SUCCESS) {
if ((*pphar)->is_data || !PHAR_G(readonly)) {
(*pphar)->is_writeable = 1;
}
@@ -1519,7 +1519,7 @@
fname_len = strlen(actual);
}
- ret = phar_open_from_fp(fp, fname, fname_len, alias, alias_len,
options, pphar, error TSRMLS_CC);
+ ret = phar_open_from_fp(fp, fname, fname_len, alias, alias_len,
options, pphar, is_data, error TSRMLS_CC);
if (actual) {
efree(actual);
@@ -1563,7 +1563,7 @@
* that the manifest is proper, then pass it to phar_parse_pharfile(). SUCCESS
* or FAILURE is returned and pphar is set to a pointer to the phar's manifest
*/
-static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char
*alias, int alias_len, int options, phar_archive_data** pphar, char **error
TSRMLS_DC) /* {{{ */
+static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char
*alias, int alias_len, int options, phar_archive_data** pphar, int is_data,
char **error TSRMLS_DC) /* {{{ */
{
const char token[] = "__HALT_COMPILER();";
const char zip_magic[] = "PK\x03\x04";
@@ -1706,7 +1706,7 @@
if (got > 512) {
if (phar_is_tar(pos, fname)) {
php_stream_rewind(fp);
- return phar_parse_tarfile(fp, fname,
fname_len, alias, alias_len, pphar, compression, error TSRMLS_CC);
+ return phar_parse_tarfile(fp, fname,
fname_len, alias, alias_len, pphar, is_data, compression, error TSRMLS_CC);
}
}
}
@@ -2380,7 +2380,7 @@
fname_len = strlen(actual);
}
- ret = phar_open_from_fp(fp, fname, fname_len, alias, alias_len,
REPORT_ERRORS, NULL, error TSRMLS_CC);
+ ret = phar_open_from_fp(fp, fname, fname_len, alias, alias_len,
REPORT_ERRORS, NULL, 0, error TSRMLS_CC);
if (actual) {
efree(actual);
@@ -3635,7 +3635,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.399 $");
+ php_info_print_table_row(2, "CVS revision", "$Revision: 1.400 $");
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");
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar_internal.h?r1=1.122&r2=1.123&diff_format=u
Index: php-src/ext/phar/phar_internal.h
diff -u php-src/ext/phar/phar_internal.h:1.122
php-src/ext/phar/phar_internal.h:1.123
--- php-src/ext/phar/phar_internal.h:1.122 Wed Apr 29 03:24:08 2009
+++ php-src/ext/phar/phar_internal.h Wed May 13 20:26:18 2009
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar_internal.h,v 1.122 2009/04/29 03:24:08 cellog Exp $ */
+/* $Id: phar_internal.h,v 1.123 2009/05/13 20:26:18 cellog Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -633,7 +633,7 @@
/* tar functions in tar.c */
int phar_is_tar(char *buf, char *fname);
-int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char
*alias, int alias_len, phar_archive_data** pphar, php_uint32 compression, char
**error TSRMLS_DC);
+int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char
*alias, int alias_len, phar_archive_data** pphar, int is_data, php_uint32
compression, char **error TSRMLS_DC);
int phar_open_or_create_tar(char *fname, int fname_len, char *alias, int
alias_len, int is_data, int options, phar_archive_data** pphar, char **error
TSRMLS_DC);
int phar_tar_flush(phar_archive_data *phar, char *user_stub, long len, int
defaultstub, char **error TSRMLS_DC);
@@ -643,7 +643,7 @@
int phar_zip_flush(phar_archive_data *archive, char *user_stub, long len, int
defaultstub, char **error TSRMLS_DC);
#ifdef PHAR_MAIN
-static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char
*alias, int alias_len, int options, phar_archive_data** pphar, char **error
TSRMLS_DC);
+static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char
*alias, int alias_len, int options, phar_archive_data** pphar, int is_data,
char **error TSRMLS_DC);
extern php_stream_wrapper php_stream_phar_wrapper;
#else
extern HashTable cached_phars;
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tar.c?r1=1.67&r2=1.68&diff_format=u
Index: php-src/ext/phar/tar.c
diff -u php-src/ext/phar/tar.c:1.67 php-src/ext/phar/tar.c:1.68
--- php-src/ext/phar/tar.c:1.67 Wed Apr 29 03:24:09 2009
+++ php-src/ext/phar/tar.c Wed May 13 20:26:18 2009
@@ -192,7 +192,7 @@
}
/* }}} */
-int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char
*alias, int alias_len, phar_archive_data** pphar, php_uint32 compression, char
**error TSRMLS_DC) /* {{{ */
+int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char
*alias, int alias_len, phar_archive_data** pphar, int is_data, php_uint32
compression, char **error TSRMLS_DC) /* {{{ */
{
char buf[512], *actual_alias = NULL, *p;
phar_entry_info entry = {0};
@@ -496,8 +496,14 @@
}
} while (read != 0);
+ if (zend_hash_exists(&(myphar->manifest), ".phar/stub.php",
sizeof(".phar/stub.php")-1)) {
+ myphar->is_data = 0;
+ } else {
+ myphar->is_data = 1;
+ }
+
/* ensure signature set */
- if (PHAR_G(require_hash) && !myphar->signature) {
+ if (!myphar->is_data && PHAR_G(require_hash) && !myphar->signature) {
php_stream_close(fp);
phar_destroy_phar_data(myphar TSRMLS_CC);
if (error) {
@@ -514,12 +520,6 @@
myphar->fp = fp;
p = strrchr(myphar->fname, '/');
- if (zend_hash_exists(&(myphar->manifest), ".phar/stub.php",
sizeof(".phar/stub.php")-1)) {
- myphar->is_data = 0;
- } else {
- myphar->is_data = 1;
- }
-
if (p) {
myphar->ext = memchr(p, '.', (myphar->fname + fname_len) - p);
if (myphar->ext == p) {
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tests/tar/require_hash.phpt?r1=1.2&r2=1.3&diff_format=u
Index: php-src/ext/phar/tests/tar/require_hash.phpt
diff -u php-src/ext/phar/tests/tar/require_hash.phpt:1.2
php-src/ext/phar/tests/tar/require_hash.phpt:1.3
--- php-src/ext/phar/tests/tar/require_hash.phpt:1.2 Fri Aug 1 13:36:19 2008
+++ php-src/ext/phar/tests/tar/require_hash.phpt Wed May 13 20:26:18 2009
@@ -18,6 +18,7 @@
$tar->init();
$tar->addFile('tar_004.php', '<?php var_dump(__FILE__);');
$tar->addFile('internal/file/here', "hi there!\n");
+$tar->addFile('.phar/stub.php', "__HALT_COMPILER();");
$tar->close();
try {
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tests/tar/files/Net_URL-1.0.15.tgz?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/phar/tests/tar/files/Net_URL-1.0.15.tgz
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php