]> granicus.if.org Git - php/commitdiff
add initial support for hashing mounted directories. Actual matching of mounted...
authorGreg Beaver <cellog@php.net>
Mon, 18 Feb 2008 04:45:42 +0000 (04:45 +0000)
committerGreg Beaver <cellog@php.net>
Mon, 18 Feb 2008 04:45:42 +0000 (04:45 +0000)
ext/phar/phar.c
ext/phar/phar_internal.h
ext/phar/tar.c
ext/phar/util.c
ext/phar/zip.c

index 575bfb278c93275234c288897491987e380745e9..f185f7d4453c74f404a5fddfe8c7900fb08946cb 100644 (file)
@@ -186,6 +186,10 @@ static void phar_destroy_phar_data(phar_archive_data *phar TSRMLS_DC) /* {{{ */
                zend_hash_destroy(&phar->manifest);
                phar->manifest.arBuckets = NULL;
        }
+       if (phar->mounted_dirs.arBuckets) {
+               zend_hash_destroy(&phar->mounted_dirs);
+               phar->mounted_dirs.arBuckets = NULL;
+       }
        if (phar->metadata) {
                zval_ptr_dtor(&phar->metadata);
                phar->metadata = 0;
@@ -838,6 +842,8 @@ int phar_open_file(php_stream *fp, char *fname, int fname_len, char *alias, int
        /* set up our manifest */
        zend_hash_init(&mydata->manifest, sizeof(phar_entry_info),
                zend_get_hash_value, destroy_phar_manifest_entry, 0);
+       zend_hash_init(&mydata->mounted_dirs, sizeof(char *),
+               zend_get_hash_value, NULL, 0);
        offset = halt_offset + manifest_len + 4;
        memset(&entry, 0, sizeof(phar_entry_info));
        entry.phar = mydata;
index f8be40ca70cca1ec87adec545046b2f78b6daf9a..7d18be8a0b0bb8bf3813de9df5ec971429712b85 100755 (executable)
@@ -261,6 +261,8 @@ struct _phar_archive_data {
        size_t                   internal_file_start;
        size_t                   halt_offset;
        HashTable                manifest;
+       /* hash of mounted directory paths */
+       HashTable                mounted_dirs;
        php_uint32               flags;
        php_uint32               min_timestamp;
        php_uint32               max_timestamp;
index 6554796052c38edbd9f9013fafa42b4f59d8d665..dd754137d2d6c7a5a51d8a3f51a7333dd985e56e 100644 (file)
@@ -170,6 +170,8 @@ int phar_open_tarfile(php_stream* fp, char *fname, int fname_len, char *alias, i
        myphar = (phar_archive_data *) ecalloc(1, sizeof(phar_archive_data));
        zend_hash_init(&myphar->manifest, sizeof(phar_entry_info),
                zend_get_hash_value, destroy_phar_manifest_entry, 0);
+       zend_hash_init(&myphar->mounted_dirs, sizeof(char *),
+               zend_get_hash_value, NULL, 0);
        myphar->is_tar = 1;
        /* remember whether this entire phar was compressed with gz/bzip2 */
        myphar->flags = compression;
index 519dfdfc500469aa62c3fc7629152181ce2b95be..c690e05e00a77ab2527dcdf3633e12f7fc8021eb 100644 (file)
@@ -108,7 +108,17 @@ int phar_mount_entry(phar_archive_data *phar, char *filename, int filename_len,
                efree(entry.filename);
                return FAILURE;
        }
-       entry.is_dir = ssb.sb.st_mode & S_IFDIR ? 1 : 0;
+       if (ssb.sb.st_mode & S_IFDIR) {
+               entry.is_dir = 1;
+               if (SUCCESS != zend_hash_add(&phar->mounted_dirs, path, path_len, (void *)&path, sizeof(char *), NULL)) {
+                       /* directory already mounted */
+                       efree(entry.link);
+                       efree(entry.filename);
+                       return FAILURE;
+               }
+       } else {
+               entry.is_dir = 0;
+       }
        entry.uncompressed_filesize = entry.compressed_filesize = ssb.sb.st_size;
        entry.flags = ssb.sb.st_mode;
        if (SUCCESS == zend_hash_add(&phar->manifest, path, path_len, (void*)&entry, sizeof(phar_entry_info), NULL)) {
index 6d5a8b522fcf06a3a2835cb5b7edb2bbce8991b5..8c64083043c8390733e3a2fe541edbf968171d9c 100644 (file)
@@ -208,6 +208,8 @@ foundit:
        /* read in central directory */
        zend_hash_init(&mydata->manifest, sizeof(phar_entry_info),
                zend_get_hash_value, destroy_phar_manifest_entry, 0);
+       zend_hash_init(&mydata->mounted_dirs, sizeof(char *),
+               zend_get_hash_value, NULL, 0);
        entry.phar = mydata;
        entry.is_zip = 1;
        entry.fp_type = PHAR_FP;