From a3c1ecaddd1f813e469059bca45a173185af3d6a Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 5 Sep 2023 09:43:08 +0200 Subject: add upstream patches for PHP 8.3 build out of sources tree --- upstream.patch | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) (limited to 'upstream.patch') diff --git a/upstream.patch b/upstream.patch index aa212c8..4f9fa16 100644 --- a/upstream.patch +++ b/upstream.patch @@ -275,3 +275,99 @@ index bc7e338b..4a8292d7 100644 -unlink($dir . "/content.xml"); -unlink($dir . "/content.txt"); -?> +From 709d850429d0d62b148bc235745c830c2f7a55be Mon Sep 17 00:00:00 2001 +From: jvoisin +Date: Sun, 25 Jun 2023 14:25:46 +0200 +Subject: [PATCH] Remove ZEND_HOT + +--- + src/sp_execute.c | 2 +- + src/sp_pcre_compat.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/sp_execute.c b/src/sp_execute.c +index 6e80b6df..f105b7f9 100644 +--- a/src/sp_execute.c ++++ b/src/sp_execute.c +@@ -89,7 +89,7 @@ inline static void is_builtin_matching( + should_disable_ht(EG(current_execute_data), function_name, param_value, param_name, SPCFG(disabled_functions_reg).disabled_functions, ht); + } + +-static void ZEND_HOT is_in_eval_and_whitelisted(zend_execute_data const* const execute_data) { ++static void is_in_eval_and_whitelisted(zend_execute_data const* const execute_data) { + sp_config_eval const* const config_eval = &(SPCFG(eval)); + + if (EXPECTED(0 == SPG(in_eval))) { +diff --git a/src/sp_pcre_compat.c b/src/sp_pcre_compat.c +index 81c51fdc..3658692e 100644 +--- a/src/sp_pcre_compat.c ++++ b/src/sp_pcre_compat.c +@@ -23,7 +23,7 @@ sp_pcre* sp_pcre_compile(const char* const pattern) { + return ret; + } + +-bool ZEND_HOT sp_is_regexp_matching_len(const sp_pcre* regexp, const char* str, size_t len) { ++bool sp_is_regexp_matching_len(const sp_pcre* regexp, const char* str, size_t len) { + int ret = 0; + + assert(NULL != regexp); +From 78668b6ef599f700ba939017dc805485452f5319 Mon Sep 17 00:00:00 2001 +From: jvoisin +Date: Sun, 25 Jun 2023 14:56:43 +0200 +Subject: [PATCH] Fix an unserialize-related warning + +This should fix `Warning: unserialize(): Extra data starting at offset 8 of 72 bytes in unserialize.php on line 4`. +On the flip side, it's not longer possible in PHP8.3 and above, when using +Snuffleupagus, to have other extensions hooking unserialize(). +--- + src/sp_unserialize.c | 18 +++++++++++++----- + 1 file changed, 13 insertions(+), 5 deletions(-) + +diff --git a/src/sp_unserialize.c b/src/sp_unserialize.c +index 641d9899..ab0d9edb 100644 +--- a/src/sp_unserialize.c ++++ b/src/sp_unserialize.c +@@ -50,8 +50,6 @@ static zend_string *sp_do_hash_hmac_sha256(char* restrict data, size_t data_len, + return hex_digest; + } + +-// ------------------ +- + PHP_FUNCTION(sp_serialize) { + zif_handler orig_handler; + +@@ -130,11 +128,16 @@ PHP_FUNCTION(sp_unserialize) { + } + } else { status = 1; } + +- zif_handler orig_handler; ++ zif_handler orig_handler = zend_hash_str_find_ptr(SPG(sp_internal_functions_hook), ZEND_STRL("unserialize")); + if (0 == status) { +- if ((orig_handler = zend_hash_str_find_ptr(SPG(sp_internal_functions_hook), ZEND_STRL("unserialize")))) { ++#if PHP_VERSION_ID >= 80300 ++ // PHP8.3 gives a warning about trailing data in unserialize strings. ++ php_unserialize_with_options(return_value, buf, buf_len - 64, opts, "unserialize"); ++#else ++ if ((orig_handler)) { + orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } ++#endif + } else { + const sp_config_unserialize *config_unserialize = &(SPCFG(unserialize)); + if (config_unserialize->dump) { +@@ -143,9 +146,14 @@ PHP_FUNCTION(sp_unserialize) { + } + if (true == config_unserialize->simulation) { + sp_log_simulation("unserialize", "Invalid HMAC for %s", serialized_str); +- if ((orig_handler = zend_hash_str_find_ptr(SPG(sp_internal_functions_hook), ZEND_STRL("unserialize")))) { ++#if PHP_VERSION_ID >= 80300 ++ // PHP8.3 gives a warning about trailing data in unserialize strings. ++ php_unserialize_with_options(return_value, buf, buf_len - 64, opts, "unserialize"); ++#else ++ if ((orig_handler)) { + orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } ++#endif + } else { + sp_log_drop("unserialize", "Invalid HMAC for %s", serialized_str); + } -- cgit