summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/sp_unserialize.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/sp_unserialize.c b/src/sp_unserialize.c
index 4442997..3e810fc 100644
--- a/src/sp_unserialize.c
+++ b/src/sp_unserialize.c
@@ -110,9 +110,27 @@ PHP_FUNCTION(sp_unserialize) {
110#endif 110#endif
111 } 111 }
112 112
113 const sp_config_unserialize *config_unserialize = &(SPCFG(unserialize));
114#if ! (PHP_VERSION_ID >= 80300)
115 zif_handler orig_handler = zend_hash_str_find_ptr(SPG(sp_internal_functions_hook), ZEND_STRL("unserialize"));
116#endif
117
113 /* 64 is the length of HMAC-256 */ 118 /* 64 is the length of HMAC-256 */
114 if (buf_len < 64) { 119 if (buf_len < 64) {
115 sp_log_drop("unserialize", "The serialized object is too small."); 120 if (true == config_unserialize->simulation) {
121 sp_log_simulation("unserialize", "The serialized object is smaller than 64: assuming there is no HMAC");
122#if PHP_VERSION_ID >= 80300
123 // PHP8.3 gives a warning about trailing data in unserialize strings.
124 php_unserialize_with_options(return_value, buf, buf_len, opts, "unserialize");
125#else
126 if ((orig_handler)) {
127 orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU);
128 }
129#endif
130 return;
131 } else {
132 sp_log_drop("unserialize", "The serialized object is too small.");
133 }
116 } 134 }
117 135
118 char* hmac = buf + buf_len - 64; 136 char* hmac = buf + buf_len - 64;
@@ -128,9 +146,6 @@ PHP_FUNCTION(sp_unserialize) {
128 } 146 }
129 } else { status = 1; } 147 } else { status = 1; }
130 148
131#if ! (PHP_VERSION_ID >= 80300)
132 zif_handler orig_handler = zend_hash_str_find_ptr(SPG(sp_internal_functions_hook), ZEND_STRL("unserialize"));
133#endif
134 if (0 == status) { 149 if (0 == status) {
135#if PHP_VERSION_ID >= 80300 150#if PHP_VERSION_ID >= 80300
136 // PHP8.3 gives a warning about trailing data in unserialize strings. 151 // PHP8.3 gives a warning about trailing data in unserialize strings.
@@ -141,7 +156,6 @@ PHP_FUNCTION(sp_unserialize) {
141 } 156 }
142#endif 157#endif
143 } else { 158 } else {
144 const sp_config_unserialize *config_unserialize = &(SPCFG(unserialize));
145 if (config_unserialize->dump) { 159 if (config_unserialize->dump) {
146 sp_log_request(config_unserialize->dump, 160 sp_log_request(config_unserialize->dump,
147 config_unserialize->textual_representation); 161 config_unserialize->textual_representation);