cellog          Wed May 13 20:25:44 2009 UTC

  Added files:                 (Branch: PHP_5_3)
    /php-src/ext/phar/tests/tar tar_nohash.phpt 
    /php-src/ext/phar/tests/tar/files   Net_URL-1.0.15.tgz 

  Modified files:              
    /php-src    NEWS 
    /php-src/ext/phar   phar.c phar_internal.h tar.c 
    /php-src/ext/phar/tests/tar require_hash.phpt 
  Log:
  fix Bug #48257: PharData throws exception with non-phar tar
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.599&r2=1.2027.2.547.2.965.2.600&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.965.2.599 
php-src/NEWS:1.2027.2.547.2.965.2.600
--- php-src/NEWS:1.2027.2.547.2.965.2.599       Tue May 12 22:18:14 2009
+++ php-src/NEWS        Wed May 13 20:25:43 2009
@@ -6,6 +6,7 @@
 
 - Disabled SQLite3::loadExtension for threaded SAPIs. (Scott)
 
+- Fixed bug #48257 (PharData throws exception with non-phar tar). (Greg)
 - Fixed bug #48227 (NumberFormatter::format leaks memory). (Felipe)
 - Fixed bug #48200 (compile failure with mbstring.c when 
   --enable-zend-multibyte is used). (Jani)
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar.c?r1=1.370.2.61&r2=1.370.2.62&diff_format=u
Index: php-src/ext/phar/phar.c
diff -u php-src/ext/phar/phar.c:1.370.2.61 php-src/ext/phar/phar.c:1.370.2.62
--- php-src/ext/phar/phar.c:1.370.2.61  Fri May  1 09:22:16 2009
+++ php-src/ext/phar/phar.c     Wed May 13 20:25:43 2009
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: phar.c,v 1.370.2.61 2009/05/01 09:22:16 tony2001 Exp $ */
+/* $Id: phar.c,v 1.370.2.62 2009/05/13 20:25:43 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.370.2.61 $");
+       php_info_print_table_row(2, "CVS revision", "$Revision: 1.370.2.62 $");
        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.109.2.30&r2=1.109.2.31&diff_format=u
Index: php-src/ext/phar/phar_internal.h
diff -u php-src/ext/phar/phar_internal.h:1.109.2.30 
php-src/ext/phar/phar_internal.h:1.109.2.31
--- php-src/ext/phar/phar_internal.h:1.109.2.30 Wed Apr 29 03:24:26 2009
+++ php-src/ext/phar/phar_internal.h    Wed May 13 20:25:43 2009
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: phar_internal.h,v 1.109.2.30 2009/04/29 03:24:26 cellog Exp $ */
+/* $Id: phar_internal.h,v 1.109.2.31 2009/05/13 20:25:43 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.55.2.27&r2=1.55.2.28&diff_format=u
Index: php-src/ext/phar/tar.c
diff -u php-src/ext/phar/tar.c:1.55.2.27 php-src/ext/phar/tar.c:1.55.2.28
--- php-src/ext/phar/tar.c:1.55.2.27    Wed Apr 29 03:24:27 2009
+++ php-src/ext/phar/tar.c      Wed May 13 20:25:43 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.1.2.1&r2=1.1.2.2&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.1.2.1 
php-src/ext/phar/tests/tar/require_hash.phpt:1.1.2.2
--- php-src/ext/phar/tests/tar/require_hash.phpt:1.1.2.1        Fri Jun 13 
22:07:44 2008
+++ php-src/ext/phar/tests/tar/require_hash.phpt        Wed May 13 20:25:43 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/tar_nohash.phpt?view=markup&rev=1.1
Index: php-src/ext/phar/tests/tar/tar_nohash.phpt
+++ php-src/ext/phar/tests/tar/tar_nohash.phpt

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to