[php-src] PHP-8.4: ext/phar: Fix repeated compression with the same algorithm
| From: | Weilin Du | Date: | Fri, 30 Oct 2026 19:10:42 +0000 |
| Subject: | [php-src] PHP-8.4: ext/phar: Fix repeated compression with the same algorithm | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143025@lists.php.net to get a copy of this message | ||
Author: Weilin Du (LamentXU123)
Date: 2026-10-31T03:10:11+08:00
Commit: https://github.com/php/php-src/commit/7dd0cebbc88f1cfceb599c303a7cba293de18b82
Raw diff: https://github.com/php/php-src/commit/7dd0cebbc88f1cfceb599c303a7cba293de18b82.diff
ext/phar: Fix repeated compression with the same algorithm
Follow-up to #25045.
Skip entries whose compression flags already match the requested algorithm
so repeated Phar::compressFiles() calls do not corrupt their contents.
Changed paths:
M ext/phar/phar_object.c
Diff:
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c
index 79ea1cf2df98..e2f36f1c7b24 100644
--- a/ext/phar/phar_object.c
+++ b/ext/phar/phar_object.c
@@ -3161,7 +3161,7 @@ static int phar_set_compression(zval *zv, void *argument) /* {{{ */
phar_entry_info *entry = (phar_entry_info *)Z_PTR_P(zv);
uint32_t compress = *(uint32_t *)argument;
- if (entry->is_deleted) {
+ if (entry->is_deleted || (entry->flags & PHAR_ENT_COMPRESSION_MASK) == compress) {
return ZEND_HASH_APPLY_KEEP;
}