summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjvoisin2022-03-20 18:43:35 +0100
committerjvoisin2022-03-20 19:07:35 +0100
commit57b345f16ccad6e5b273c58e819ca5adefdcbf72 (patch)
tree4ee854853720a8a559ed7d34c977be8f42ff2bb6 /src
parent70aae5917737e42f392edc00ceb7af35b7740eb8 (diff)
Fix compilation on PHP<7.2
Diffstat (limited to 'src')
-rw-r--r--src/sp_config_keywords.c2
-rw-r--r--src/sp_php_compat.h2
-rw-r--r--src/sp_unserialize.c4
-rw-r--r--src/tests/broken_configuration/encrypt_regexp_cookies_bad_regexp.phpt4
-rw-r--r--src/tests/disable_function/disabled_functions_shell_exec_closure.phpt1
5 files changed, 8 insertions, 5 deletions
diff --git a/src/sp_config_keywords.c b/src/sp_config_keywords.c
index 9a9b608..f7be731 100644
--- a/src/sp_config_keywords.c
+++ b/src/sp_config_keywords.c
@@ -321,7 +321,7 @@ SP_PARSE_FN(parse_disabled_functions) {
321 goto out; 321 goto out;
322 } 322 }
323 if (df->filename && (*ZSTR_VAL(df->filename) != '/') && 323 if (df->filename && (*ZSTR_VAL(df->filename) != '/') &&
324 (0 != strncmp(ZSTR_VAL(df->filename), ZEND_STRL("phar://")))) { 324 (0 != strncmp(ZSTR_VAL(df->filename), "phar://", sizeof("phar://")))) {
325 sp_log_err("config", "Invalid configuration line: 'sp.disabled_functions': '.filename' must be an absolute path or a phar archive on line %zu", parsed_rule->lineno); 325 sp_log_err("config", "Invalid configuration line: 'sp.disabled_functions': '.filename' must be an absolute path or a phar archive on line %zu", parsed_rule->lineno);
326 goto out; 326 goto out;
327 } 327 }
diff --git a/src/sp_php_compat.h b/src/sp_php_compat.h
index 04914b4..2334f62 100644
--- a/src/sp_php_compat.h
+++ b/src/sp_php_compat.h
@@ -111,7 +111,7 @@ static inline void php_hash_string_xor_char(unsigned char *out, const unsigned c
111 111
112static inline void php_hash_hmac_prep_key(unsigned char *K, const php_hash_ops *ops, void *context, const unsigned char *key, const size_t key_len) { 112static inline void php_hash_hmac_prep_key(unsigned char *K, const php_hash_ops *ops, void *context, const unsigned char *key, const size_t key_len) {
113 memset(K, 0, ops->block_size); 113 memset(K, 0, ops->block_size);
114 if (key_len > ops->block_size) { 114 if (key_len > (size_t)ops->block_size) {
115 /* Reduce the key first */ 115 /* Reduce the key first */
116#if PHP_VERSION_ID < 80100 116#if PHP_VERSION_ID < 80100
117 ops->hash_init(context); 117 ops->hash_init(context);
diff --git a/src/sp_unserialize.c b/src/sp_unserialize.c
index c2173d3..2e7c173 100644
--- a/src/sp_unserialize.c
+++ b/src/sp_unserialize.c
@@ -18,7 +18,11 @@ static zend_string *sp_do_hash_hmac_sha256(char *data, size_t data_len, char *ke
18 zend_string_release_ex(algo, 0); 18 zend_string_release_ex(algo, 0);
19#endif 19#endif
20 20
21#if PHP_VERSION_ID < 70200
22 if (!ops) {
23#else
21 if (!ops || !ops->is_crypto) { 24 if (!ops || !ops->is_crypto) {
25#endif
22 sp_log_err("hmac", "unsupported hash algorithm: sha256"); 26 sp_log_err("hmac", "unsupported hash algorithm: sha256");
23 return NULL; 27 return NULL;
24 } 28 }
diff --git a/src/tests/broken_configuration/encrypt_regexp_cookies_bad_regexp.phpt b/src/tests/broken_configuration/encrypt_regexp_cookies_bad_regexp.phpt
index f660f28..2b9f709 100644
--- a/src/tests/broken_configuration/encrypt_regexp_cookies_bad_regexp.phpt
+++ b/src/tests/broken_configuration/encrypt_regexp_cookies_bad_regexp.phpt
@@ -15,6 +15,4 @@ EOF;
15--FILE-- 15--FILE--
16<?php var_dump($_COOKIE); ?> 16<?php var_dump($_COOKIE); ?>
17--EXPECTF-- 17--EXPECTF--
18Fatal error: [snuffleupagus][127.0.0.1][config][log] Invalid configuration file in Unknown on line 0 18%AFatal error: [snuffleupagus][127.0.0.1][config][log] Invalid regexp '^super_co[a-z+$' for '.name_r()' on line 2 in Unknown on line 0
19%A
20Fatal error: [snuffleupagus][127.0.0.1][config][log] Invalid regexp '^super_co[a-z+$' for '.name_r()' on line 2 in Unknown on line 0
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_closure.phpt b/src/tests/disable_function/disabled_functions_shell_exec_closure.phpt
index fd9343b..ee1635c 100644
--- a/src/tests/disable_function/disabled_functions_shell_exec_closure.phpt
+++ b/src/tests/disable_function/disabled_functions_shell_exec_closure.phpt
@@ -2,6 +2,7 @@
2Disable functions - shell_exec via closure 2Disable functions - shell_exec via closure
3--SKIPIF-- 3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> 4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?>
5<?php if (PHP_VERSION_ID < 80100) print "skip"; ?>
5--INI-- 6--INI--
6sp.configuration_file={PWD}/config/disabled_functions_extra.ini 7sp.configuration_file={PWD}/config/disabled_functions_extra.ini
7--FILE-- 8--FILE--