From 44aea65486eb74640c35fa83da7e2b1a022cbf8e Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Tue, 14 Oct 2025 18:48:10 +0200 Subject: [PATCH] phar: Change hacky check into an exception (#20160) phar_metadata_tracker_unserialize_or_copy() is only ever preceded by phar_metadata_tracker_has_data() which won't throw. This check is quite hacky and it should always be the responsibility of the caller to avoid calling this, even the comment acknowledges this is a hack. --- ext/phar/phar.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/ext/phar/phar.c b/ext/phar/phar.c index d2c25dfbdb7..6d408708fc2 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -595,13 +595,9 @@ zend_result phar_metadata_tracker_unserialize_or_copy(phar_metadata_tracker *tra const bool has_unserialize_options = unserialize_options != NULL && zend_hash_num_elements(unserialize_options) > 0; /* It should be impossible to create a zval in a persistent phar/entry. */ ZEND_ASSERT(!persistent || Z_ISUNDEF(tracker->val)); + ZEND_ASSERT(!EG(exception)); if (Z_ISUNDEF(tracker->val) || has_unserialize_options) { - if (EG(exception)) { - /* Because other parts of the phar code haven't been updated to check for exceptions after doing something that may throw, - * check for exceptions before potentially serializing/unserializing instead. */ - return FAILURE; - } /* Persistent phars should always be unserialized. */ const char *start; /* Assert it should not be possible to create raw data in a persistent phar (i.e. from cache_list) */