cellog          Mon Jun 23 04:00:23 2008 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/ext/phar   phar.phar phar_object.c 
    /php-src/ext/phar/tests     phar_buildfromdirectory4.phpt 
  Log:
  true fix for potential segfault in phar_build
  
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar.phar?r1=1.7.2.25&r2=1.7.2.26&diff_format=u
Index: php-src/ext/phar/phar.phar
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar_object.c?r1=1.266.2.30&r2=1.266.2.31&diff_format=u
Index: php-src/ext/phar/phar_object.c
diff -u php-src/ext/phar/phar_object.c:1.266.2.30 
php-src/ext/phar/phar_object.c:1.266.2.31
--- php-src/ext/phar/phar_object.c:1.266.2.30   Sun Jun 22 16:35:26 2008
+++ php-src/ext/phar/phar_object.c      Mon Jun 23 04:00:22 2008
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: phar_object.c,v 1.266.2.30 2008/06/22 16:35:26 sfox Exp $ */
+/* $Id: phar_object.c,v 1.266.2.31 2008/06/23 04:00:22 cellog Exp $ */
 
 #include "phar_internal.h"
 #include "func_interceptors.h"
@@ -1614,7 +1614,16 @@
                if (error) {
                        efree(error);
                }
-               contents_len = php_stream_copy_to_stream(fp, data->fp, 
PHP_STREAM_COPY_ALL);
+               /* convert to PHAR_UFP */
+               if (data->internal_file->fp_type == PHAR_MOD) {
+                       php_stream_close(data->internal_file->fp);
+               }
+               data->internal_file->fp = NULL;
+               data->internal_file->fp_type = PHAR_UFP;
+               data->internal_file->offset_abs = data->internal_file->offset = 
php_stream_tell(p_obj->fp);
+               contents_len = php_stream_copy_to_stream(fp, p_obj->fp, 
PHP_STREAM_COPY_ALL);
+               data->internal_file->uncompressed_filesize = 
data->internal_file->compressed_filesize =
+                       php_stream_tell(p_obj->fp) - 
data->internal_file->offset;
        }
        if (close_fp) {
                php_stream_close(fp);
@@ -1632,15 +1641,6 @@
        data->internal_file->compressed_filesize = 
data->internal_file->uncompressed_filesize = contents_len;
        phar_entry_delref(data TSRMLS_CC);
 
-       if (++p_obj->count && p_obj->count % 900) {
-               /* every 900 files, flush so we remove open temp file handles, 
fixes Bug #45218 */
-               phar_flush(p_obj->p->arc.archive, 0, 0, 0, &error TSRMLS_CC);
-               if (error) {
-                       zend_throw_exception_ex(phar_ce_PharException, 0 
TSRMLS_CC, error);
-                       efree(error);
-                       return ZEND_HASH_APPLY_STOP;
-               }
-       }
        return ZEND_HASH_APPLY_KEEP;
 }
 /* }}} */
@@ -1694,6 +1694,7 @@
 
        if (SUCCESS != object_init_ex(iteriter, 
spl_ce_RecursiveIteratorIterator)) {
                zval_ptr_dtor(&iter);
+               zval_ptr_dtor(&iteriter);
                zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 
TSRMLS_CC, "Unable to instantiate directory iterator for %s", 
phar_obj->arc.archive->fname);
                RETURN_FALSE;
        }
@@ -1714,6 +1715,7 @@
                MAKE_STD_ZVAL(regexiter);
 
                if (SUCCESS != object_init_ex(regexiter, spl_ce_RegexIterator)) 
{
+                       zval_ptr_dtor(&iteriter);
                        zval_dtor(regexiter);
                        zend_throw_exception_ex(spl_ce_BadMethodCallException, 
0 TSRMLS_CC, "Unable to instantiate regex iterator for %s", 
phar_obj->arc.archive->fname);
                        RETURN_FALSE;
@@ -1748,6 +1750,7 @@
                        efree(error);
                }
        } else {
+               zval_ptr_dtor(&iteriter);
                php_stream_close(pass.fp);
        }
 }
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tests/phar_buildfromdirectory4.phpt?r1=1.2&r2=1.2.2.1&diff_format=u
Index: php-src/ext/phar/tests/phar_buildfromdirectory4.phpt
diff -u php-src/ext/phar/tests/phar_buildfromdirectory4.phpt:1.2 
php-src/ext/phar/tests/phar_buildfromdirectory4.phpt:1.2.2.1
--- php-src/ext/phar/tests/phar_buildfromdirectory4.phpt:1.2    Sun May 11 
19:17:50 2008
+++ php-src/ext/phar/tests/phar_buildfromdirectory4.phpt        Mon Jun 23 
04:00:23 2008
@@ -5,6 +5,7 @@
 --INI--
 phar.require_hash=0
 phar.readonly=0
+open_basedir=
 --FILE--
 <?php
 



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

Reply via email to