From: Christoph M. Becker Date: Tue, 28 Jan 2020 09:40:00 +0000 (+0100) Subject: Merge branch 'PHP-7.4' X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9a5ea0de69512da23e63b7a4f8fcadc96f7a9886;p=php Merge branch 'PHP-7.4' * PHP-7.4: Fix #76584: PharFileInfo::decompress not working --- 9a5ea0de69512da23e63b7a4f8fcadc96f7a9886 diff --cc ext/phar/phar_object.c index 8a4599d5f4,6cf097e36f..027c78a18c --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@@ -5108,12 -5093,24 +5109,24 @@@ PHP_METHOD(PharFileInfo, decompress /* re-populate after copy-on-write */ entry_obj->entry = zend_hash_str_find_ptr(&phar->manifest, entry_obj->entry->filename, entry_obj->entry->filename_len); } - if (!entry_obj->entry->fp) { - if (FAILURE == phar_open_archive_fp(entry_obj->entry->phar)) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot decompress entry \"%s\", phar error: Cannot open phar archive \"%s\" for reading", entry_obj->entry->filename, entry_obj->entry->phar->fname); + switch (entry_obj->entry->flags & PHAR_ENT_COMPRESSION_MASK) { + case PHAR_ENT_COMPRESSED_GZ: + compression_type = "gzip"; + break; + case PHAR_ENT_COMPRESSED_BZ2: + compression_type = "bz2"; + break; + default: + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, + "Cannot decompress file compressed with unknown compression type"); - return; + RETURN_THROWS(); - } - entry_obj->entry->fp_type = PHAR_FP; + } + /* decompress this file indirectly */ + if (SUCCESS != phar_open_entry_fp(entry_obj->entry, &error, 1)) { + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, + "Phar error: Cannot decompress %s-compressed file \"%s\" in phar \"%s\": %s", compression_type, entry_obj->entry->filename, entry_obj->entry->phar->fname, error); + efree(error); + return; } entry_obj->entry->old_flags = entry_obj->entry->flags;