cellog          Thu May 29 17:34:50 2008 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/ext/phar   phar.c 
    /php-src/ext/phar/tests/zip unixzip.phpt 
  Log:
  fix PECL bug #13981: Third-party zips fail entry interrogation
  
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar.c?r1=1.370.2.6&r2=1.370.2.7&diff_format=u
Index: php-src/ext/phar/phar.c
diff -u php-src/ext/phar/phar.c:1.370.2.6 php-src/ext/phar/phar.c:1.370.2.7
--- php-src/ext/phar/phar.c:1.370.2.6   Wed May 28 21:42:21 2008
+++ php-src/ext/phar/phar.c     Thu May 29 17:34:49 2008
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: phar.c,v 1.370.2.6 2008/05/28 21:42:21 stas Exp $ */
+/* $Id: phar.c,v 1.370.2.7 2008/05/29 17:34:49 cellog Exp $ */
 
 #define PHAR_MAIN 1
 #include "phar_internal.h"
@@ -1980,15 +1980,16 @@
                        spprintf(error, 0, "phar error: internal corruption of 
zip-based phar \"%s\" (cannot read local file header for file \"%s\")", 
idata->phar->fname, entry->filename);
                        return FAILURE;
                }
-               /* fix up for big-endian systems */
-               /* verify local header if not yet verified */
+               /* verify local header */
                if (entry->filename_len != PHAR_ZIP_16(local.filename_len) || 
entry->crc32 != PHAR_ZIP_32(local.crc32) || entry->uncompressed_filesize != 
PHAR_ZIP_32(local.uncompsize) || entry->compressed_filesize != 
PHAR_ZIP_32(local.compsize)) {
                        spprintf(error, 0, "phar error: internal corruption of 
zip-based phar \"%s\" (local head of file \"%s\" does not match central 
directory)", idata->phar->fname, entry->filename);
                        return FAILURE;
                }
-               if (-1 == php_stream_seek(idata->phar->fp, 
PHAR_ZIP_16(local.filename_len) + PHAR_ZIP_16(local.extra_len), SEEK_CUR)) {
-                       spprintf(error, 0, "phar error: internal corruption of 
zip-based phar \"%s\" (cannot seek to start of file data for file \"%s\")", 
idata->phar->fname, entry->filename);
-                       return FAILURE;
+               /* construct actual offset to file start - local extra_len can 
be different from central extra_len */
+               entry->offset = entry->offset_abs =
+                       sizeof(local) + entry->header_offset + 
PHAR_ZIP_16(local.filename_len) + PHAR_ZIP_16(local.extra_len);
+               if (idata->zero != entry->offset_abs) {
+                       idata->zero = entry->offset_abs;
                }
        }
        php_stream_seek(fp, idata->zero, SEEK_SET);     
@@ -3051,7 +3052,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.6 $");
+       php_info_print_table_row(2, "CVS revision", "$Revision: 1.370.2.7 $");
        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/tests/zip/unixzip.phpt?r1=1.2&r2=1.2.2.1&diff_format=u
Index: php-src/ext/phar/tests/zip/unixzip.phpt
diff -u php-src/ext/phar/tests/zip/unixzip.phpt:1.2 
php-src/ext/phar/tests/zip/unixzip.phpt:1.2.2.1
--- php-src/ext/phar/tests/zip/unixzip.phpt:1.2 Sun Apr 20 05:50:39 2008
+++ php-src/ext/phar/tests/zip/unixzip.phpt     Thu May 29 17:34:50 2008
@@ -10,7 +10,8 @@
        if ($b->isDir()) {
                echo "dir " . $b->getPathName() . "\n";
        } else {
-               echo $b->getPathName() . "\n";
+               echo $b->getPathName(), "\n";
+               echo file_get_contents($b->getPathName()), "\n";
        }
 }
 if (isset($a['notempty/hi.txt'])) {
@@ -19,8 +20,10 @@
 ?>
 ===DONE===
 --EXPECTF--
-dir phar://%szip.zip%cempty
-phar://%szip.zip%chi.txt
-dir phar://%szip.zip%cnotempty
-phar://%szip.zip/notempty/hi.txt
-===DONE===
+dir phar:///home/cellog/workspace/php5/ext/phar/tests/zip/files/zip.zip/empty
+phar:///home/cellog/workspace/php5/ext/phar/tests/zip/files/zip.zip/hi.txt
+hi there
+
+dir 
phar:///home/cellog/workspace/php5/ext/phar/tests/zip/files/zip.zip/notempty
+phar:///home/cellog/workspace/php5/ext/phar/tests/zip/files/zip.zip/notempty/hi.txt
+===DONE===
\ No newline at end of file



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

Reply via email to