]> granicus.if.org Git - php/commitdiff
2 fixes, merge minor fixes from pecl/phar. Merge in corrected fix from pecl/phar...
authorGreg Beaver <cellog@php.net>
Sun, 31 Aug 2008 02:14:03 +0000 (02:14 +0000)
committerGreg Beaver <cellog@php.net>
Sun, 31 Aug 2008 02:14:03 +0000 (02:14 +0000)
ext/phar/phar.phar
ext/phar/stream.c
ext/phar/util.c
ext/phar/zip.c

index 2ee3026cc1fe9948785ae2d38db7ade5c9e25dbb..06cbf51a1f338a0c50dfaaa4be9130c67e4a686b 100755 (executable)
Binary files a/ext/phar/phar.phar and b/ext/phar/phar.phar differ
index 729847ca2f1879ad888c555e8871c0e669f465d8..e6408ff66931cf9a1112b81c8890926590a32329 100644 (file)
@@ -910,6 +910,7 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char
                                memcpy(new_str_key, resource_to->path + 1, to_len);
                                memcpy(new_str_key + to_len, str_key + from_len, key_len - from_len);
                                new_str_key[new_key_len] = 0;
+
                                is_modified = 1;
                                entry->is_modified = 1;
                                efree(entry->filename);
@@ -917,7 +918,6 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char
                                entry->filename_len = new_key_len;
 
                                PHAR_ZSTR(new_str_key, new_key);
-
 #if PHP_VERSION_ID < 50300
                                zend_hash_update_current_key_ex(&phar->manifest, key_type, new_key, new_key_len, 0, NULL);
 #else
index ea5159840d68de3e91489c08bed636b528952f5e..12a046b3ba3251a01724fe02ea15ea2b00c83c84 100644 (file)
@@ -686,7 +686,7 @@ really_get_entry:
                if (entry->link) {
                        efree(entry->link);
                        entry->link = NULL;
-                       entry->tar_type = (entry->tar_type ? TAR_FILE : 0);
+                       entry->tar_type = (entry->is_tar ? TAR_FILE : 0);
                }
 
                if (for_write) {
@@ -740,7 +740,7 @@ phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char
        phar_unixify_path_separators(path, path_len);
 #endif
 
-       is_dir = (path_len > 0 && path != NULL) ? path[path_len - 1] == '/' : 0;
+       is_dir = (path_len && path[path_len - 1] == '/') ? 1 : 0;
 
        if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, error TSRMLS_CC)) {
                return NULL;
@@ -877,7 +877,7 @@ int phar_copy_entry_fp(phar_entry_info *source, phar_entry_info *dest, char **er
        if (dest->link) {
                efree(dest->link);
                dest->link = NULL;
-               dest->tar_type = (dest->tar_type ? TAR_FILE : 0);
+               dest->tar_type = (dest->is_tar ? TAR_FILE : 0);
        }
 
        dest->fp_type = PHAR_MOD;
@@ -1082,7 +1082,7 @@ int phar_create_writeable_entry(phar_archive_data *phar, phar_entry_info *entry,
        if (entry->link) {
                efree(entry->link);
                entry->link = NULL;
-               entry->tar_type = (entry->tar_type ? TAR_FILE : 0);
+               entry->tar_type = (entry->is_tar ? TAR_FILE : 0);
        }
 
        entry->fp = php_stream_fopen_tmpfile();
@@ -1139,7 +1139,7 @@ int phar_separate_entry_fp(phar_entry_info *entry, char **error TSRMLS_DC) /* {{
        if (entry->link) {
                efree(entry->link);
                entry->link = NULL;
-               entry->tar_type = (entry->tar_type ? TAR_FILE : 0);
+               entry->tar_type = (entry->is_tar ? TAR_FILE : 0);
        }
 
        entry->offset = 0;
@@ -1459,7 +1459,7 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
        phar_unixify_path_separators(path, path_len);
 #endif
 
-       is_dir = path_len && (path[path_len - 1] == '/');
+       is_dir = (path_len && (path[path_len - 1] == '/')) ? 1 : 0;
 
        if (error) {
                *error = NULL;
@@ -1550,7 +1550,6 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
                        } else {
                                char *test;
                                int test_len;
-                               phar_entry_info *entry;
                                php_stream_statbuf ssb;
 
                                if (SUCCESS != zend_hash_find(&phar->manifest, str_key, keylen, (void **) &entry)) {
@@ -1663,6 +1662,7 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end,
                zval_dtor(zkey);
                return FAILURE;
        }
+
 #if PHP_VERSION_ID < 50300
        if (FAILURE == zend_fcall_info_init(openssl, &fci, &fcc TSRMLS_CC)) {
 #else
@@ -1680,7 +1680,9 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end,
        fci.params = zp;
 #if PHP_VERSION_ID < 50300
        ++(zdata->refcount);
-       ++(zsig->refcount);
+       if (!is_sign) {
+               ++(zsig->refcount);
+       }
        ++(zkey->refcount);
 #else
        Z_ADDREF_P(zdata);
@@ -1709,7 +1711,9 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end,
        efree(openssl);
 #if PHP_VERSION_ID < 50300
        --(zdata->refcount);
-       --(zsig->refcount);
+       if (!is_sign) {
+               --(zsig->refcount);
+       }
        --(zkey->refcount);
 #else
        Z_DELREF_P(zdata);
index cd40e22dc5bda3f8f112cdccd14dff1ddd2b5252..26d873239f92b6ee6cc09f4ea5dca0d93493e14e 100644 (file)
@@ -159,7 +159,6 @@ int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias,
        phar_zip_dir_end locator;
        char buf[sizeof(locator) + 65536];
        long size;
-       size_t read;
        php_uint16 i;
        phar_archive_data *mydata = NULL;
        phar_entry_info entry = {0};
@@ -181,7 +180,7 @@ int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias,
                php_stream_seek(fp, 0, SEEK_SET);
        }
 
-       if (!(read = php_stream_read(fp, buf, size))) {
+       if (!php_stream_read(fp, buf, size)) {
                php_stream_close(fp);
                if (error) {
                        spprintf(error, 4096, "phar error: unable to read in data to search for end of central directory in zip-based phar \"%s\"", fname);
@@ -491,7 +490,6 @@ foundit:
                                php_stream_filter_remove(filter, 1 TSRMLS_CC);
 
                        } else if (entry.flags & PHAR_ENT_COMPRESSED_BZ2) {
-                               php_stream_filter *filter;
                                filter = php_stream_filter_create("bzip2.decompress", NULL, php_stream_is_persistent(fp) TSRMLS_CC);
 
                                if (!filter) {