cellog          Wed May 21 22:00:43 2008 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/ext/phar   phar.c phar_internal.h phar_object.c tar.c 
  Log:
  fix offset detection in tar files
  
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar.c?r1=1.370.2.3&r2=1.370.2.4&diff_format=u
Index: php-src/ext/phar/phar.c
diff -u php-src/ext/phar/phar.c:1.370.2.3 php-src/ext/phar/phar.c:1.370.2.4
--- php-src/ext/phar/phar.c:1.370.2.3   Sat May 17 20:07:22 2008
+++ php-src/ext/phar/phar.c     Wed May 21 22:00:43 2008
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: phar.c,v 1.370.2.3 2008/05/17 20:07:22 cellog Exp $ */
+/* $Id: phar.c,v 1.370.2.4 2008/05/21 22:00:43 cellog Exp $ */
 
 #define PHAR_MAIN 1
 #include "phar_internal.h"
@@ -101,7 +101,7 @@
  * When all uses of a phar have been concluded, this frees the manifest
  * and the phar slot
  */
-static void phar_destroy_phar_data(phar_archive_data *phar TSRMLS_DC) /* {{{ */
+void phar_destroy_phar_data(phar_archive_data *phar TSRMLS_DC) /* {{{ */
 {
        if (phar->alias && phar->alias != phar->fname) {
                efree(phar->alias);
@@ -3025,7 +3025,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.3 $");
+       php_info_print_table_row(2, "CVS revision", "$Revision: 1.370.2.4 $");
        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.3&r2=1.109.2.4&diff_format=u
Index: php-src/ext/phar/phar_internal.h
diff -u php-src/ext/phar/phar_internal.h:1.109.2.3 
php-src/ext/phar/phar_internal.h:1.109.2.4
--- php-src/ext/phar/phar_internal.h:1.109.2.3  Sat May 17 20:07:22 2008
+++ php-src/ext/phar/phar_internal.h    Wed May 21 22:00:43 2008
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: phar_internal.h,v 1.109.2.3 2008/05/17 20:07:22 cellog Exp $ */
+/* $Id: phar_internal.h,v 1.109.2.4 2008/05/21 22:00:43 cellog Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -395,6 +395,7 @@
 void phar_request_initialize(TSRMLS_D);
 
 void phar_object_init(TSRMLS_D);
+void phar_destroy_phar_data(phar_archive_data *phar TSRMLS_DC);
 
 int phar_open_entry_file(phar_archive_data *phar, phar_entry_info *entry, char 
**error TSRMLS_DC);
 int phar_open_filename(char *fname, int fname_len, char *alias, int alias_len, 
int options, phar_archive_data** pphar, char **error TSRMLS_DC);
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar_object.c?r1=1.266.2.8&r2=1.266.2.9&diff_format=u
Index: php-src/ext/phar/phar_object.c
diff -u php-src/ext/phar/phar_object.c:1.266.2.8 
php-src/ext/phar/phar_object.c:1.266.2.9
--- php-src/ext/phar/phar_object.c:1.266.2.8    Wed May 21 20:24:40 2008
+++ php-src/ext/phar/phar_object.c      Wed May 21 22:00:43 2008
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: phar_object.c,v 1.266.2.8 2008/05/21 20:24:40 cellog Exp $ */
+/* $Id: phar_object.c,v 1.266.2.9 2008/05/21 22:00:43 cellog Exp $ */
 
 #include "phar_internal.h"
 #include "func_interceptors.h"
@@ -1893,6 +1893,15 @@
        if (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), newpath, 
phar->fname_len, (void **) &pphar)) {
                if ((*pphar)->fname_len == phar->fname_len && 
!memcmp((*pphar)->fname, phar->fname, phar->fname_len)) {
                        if (!zend_hash_num_elements(&phar->manifest)) {
+                               (*pphar)->is_tar = phar->is_tar;
+                               (*pphar)->is_zip = phar->is_zip;
+                               (*pphar)->is_data = phar->is_data;
+                               (*pphar)->flags = phar->flags;
+                               (*pphar)->fp = phar->fp;
+                               phar->fp = NULL;
+                               phar_destroy_phar_data(phar);
+                               phar = *pphar;
+                               newpath = oldpath;
                                goto its_ok;
                        }
                }
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tar.c?r1=1.55.2.1&r2=1.55.2.2&diff_format=u
Index: php-src/ext/phar/tar.c
diff -u php-src/ext/phar/tar.c:1.55.2.1 php-src/ext/phar/tar.c:1.55.2.2
--- php-src/ext/phar/tar.c:1.55.2.1     Thu May 15 23:46:29 2008
+++ php-src/ext/phar/tar.c      Wed May 21 22:00:43 2008
@@ -225,10 +225,11 @@
        entry.is_tar = 1;
        entry.is_crc_checked = 1;
        entry.phar = myphar;
+       pos += sizeof(buf);
        do {
                phar_entry_info *newentry;
 
-               pos += sizeof(buf);
+               pos = php_stream_tell(fp);
                hdr = (tar_header*) buf;
                sum1 = phar_tar_number(hdr->checksum, sizeof(hdr->checksum));
                if (sum1 == 0 && phar_tar_checksum(buf, sizeof(buf)) == 0) {
@@ -385,7 +386,6 @@
                        }
                }
                size = (size+511)&~511;
-               pos += size;
                if (((hdr->typeflag == 0) || (hdr->typeflag == TAR_FILE)) && 
size > 0) {
                        /* this is not good enough - seek succeeds even on 
truncated tars */
                        php_stream_seek(fp, size, SEEK_CUR);



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

Reply via email to