]> granicus.if.org Git - php/commitdiff
amend zip test to actually test file perms creation/reading and fix severely broken...
authorGreg Beaver <cellog@php.net>
Sun, 20 Apr 2008 05:41:41 +0000 (05:41 +0000)
committerGreg Beaver <cellog@php.net>
Sun, 20 Apr 2008 05:41:41 +0000 (05:41 +0000)
ext/phar/tests/zip/033.phpt
ext/phar/zip.c

index 6cb2e8afd26f318f07f5973141175a5a7b166fbe..3c1e2de7bc14940c4439d2ceb2a180835eb78ba3 100644 (file)
@@ -9,6 +9,7 @@ phar.require_hash=0
 <?php
 
 $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.zip';
 $alias = 'phar://hio';
 
 $phar = new Phar($fname);
@@ -20,7 +21,9 @@ $phar->stopBuffering();
 try {
        var_dump($phar['a.php']->isExecutable());
        $phar['a.php']->chmod(0777);
-       var_dump($phar['a.php']->isExecutable());
+       copy($fname, $fname2);
+       $phar2 = new Phar($fname2);
+       var_dump($phar2['a.php']->isExecutable());
        $phar['a.php']->chmod(0666);
        var_dump($phar['a.php']->isExecutable());
        echo "test dir\n";
@@ -36,8 +39,9 @@ try {
 ?>
 ===DONE===
 --CLEAN--
-<?php 
+<?php
 unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.zip');
 ?>
 --EXPECT--
 bool(false)
index 460321f0c157e6f6b43d645f1c35c194edc330ef..cd35b874fa8f9417f150fd52dd7cd0e988766358 100644 (file)
@@ -40,32 +40,34 @@ static int phar_zip_process_extra(php_stream *fp, phar_entry_info *entry, php_ui
                phar_zip_extra_field_header header;
                phar_zip_unix3 unix3;
        } h;
+       int read;
 
        do {
                if (sizeof(h.header) != php_stream_read(fp, (char *) &h.header, sizeof(h.header))) {
                        return FAILURE;
                }
-               /* clean up header for big-endian systems */
-               if (h.header.tag[0] != 'u' || h.header.tag[1] != 'n') {
+               if (h.header.tag[0] != 'n' || h.header.tag[1] != 'u') {
                        /* skip to next header */
                        php_stream_seek(fp, PHAR_GET_16(h.header.size), SEEK_CUR);
                        len -= PHAR_GET_16(h.header.size) + 4;
                        continue;
                }
                /* unix3 header found */
-               /* clean up header for big-endian systems */
-               if (sizeof(h.unix3) != php_stream_read(fp, (char *) &h.unix3, sizeof(h.unix3))) {
-                       if (PHAR_GET_16(h.unix3.size) > sizeof(h.unix3) - 4) {
-                               /* skip symlink filename - we may add this support in later */
-                               php_stream_seek(fp, h.unix3.size - sizeof(h.unix3.size), SEEK_CUR);
-                       }
-                       /* set permissions */
-                       entry->flags &= PHAR_ENT_COMPRESSION_MASK;
-                       if (entry->is_dir) {
-                               entry->flags |= PHAR_GET_16(h.unix3.perms) & PHAR_ENT_PERM_DEF_DIR;
-                       } else {
-                               entry->flags |= PHAR_GET_16(h.unix3.perms) & PHAR_ENT_PERM_DEF_FILE;
-                       }
+               read = php_stream_read(fp, (char *) &(h.unix3.crc32), sizeof(h.unix3) - sizeof(h.header));
+               len -= read + 4;
+               if (sizeof(h.unix3) - sizeof(h.header) != read) {
+                       return FAILURE;
+               }
+               if (PHAR_GET_16(h.unix3.size) > sizeof(h.unix3) - 4) {
+                       /* skip symlink filename - we may add this support in later */
+                       php_stream_seek(fp, h.unix3.size - sizeof(h.unix3.size), SEEK_CUR);
+               }
+               /* set permissions */
+               entry->flags &= PHAR_ENT_COMPRESSION_MASK;
+               if (entry->is_dir) {
+                       entry->flags |= PHAR_GET_16(h.unix3.perms) & PHAR_ENT_PERM_MASK;
+               } else {
+                       entry->flags |= PHAR_GET_16(h.unix3.perms) & PHAR_ENT_PERM_MASK;
                }
        } while (len);
        return SUCCESS;