diff options
| author | Ben Fuhrmannek | 2021-11-30 12:57:06 +0100 |
|---|---|---|
| committer | Ben Fuhrmannek | 2021-11-30 12:57:06 +0100 |
| commit | e22065c7ba31d000e93f57dce8a2caae50375d5e (patch) | |
| tree | 7703ecce07857a4bf64e1a2aae052d8795b6afc8 | |
| parent | 0462573a7678468b19bc4865c75f7b82dbedbe03 (diff) | |
php 8.1 compatibility
| -rw-r--r-- | .gitignore | 5 | ||||
| -rw-r--r-- | src/sp_php_compat.h | 9 |
2 files changed, 14 insertions, 0 deletions
| @@ -19,6 +19,10 @@ src/tests/*/*.log | |||
| 19 | src/tests/*/*.out | 19 | src/tests/*/*.out |
| 20 | src/tests/*/*.sh | 20 | src/tests/*/*.sh |
| 21 | src/tests/*/*.php | 21 | src/tests/*/*.php |
| 22 | src/tests/*/phpt.* | ||
| 23 | |||
| 24 | .vscode/ | ||
| 25 | |||
| 22 | # generated by re2c or copied from cached version | 26 | # generated by re2c or copied from cached version |
| 23 | src/sp_config_scanner.c | 27 | src/sp_config_scanner.c |
| 24 | # Files generated by phpize, configure and make | 28 | # Files generated by phpize, configure and make |
| @@ -47,4 +51,5 @@ src/Makefile.objects | |||
| 47 | src/missing | 51 | src/missing |
| 48 | src/mkinstalldirs | 52 | src/mkinstalldirs |
| 49 | src/run-tests.php | 53 | src/run-tests.php |
| 54 | src/*.dep | ||
| 50 | doc/build/ | 55 | doc/build/ |
diff --git a/src/sp_php_compat.h b/src/sp_php_compat.h index d1102a8..04914b4 100644 --- a/src/sp_php_compat.h +++ b/src/sp_php_compat.h | |||
| @@ -100,6 +100,7 @@ static zend_always_inline void zend_string_efree(zend_string *s) | |||
| 100 | #endif | 100 | #endif |
| 101 | 101 | ||
| 102 | // copied from PHP 8.0.11 sources, ext/hash/hash.c | 102 | // copied from PHP 8.0.11 sources, ext/hash/hash.c |
| 103 | // slightly modified for PHP 8.1 compatibility | ||
| 103 | 104 | ||
| 104 | static inline void php_hash_string_xor_char(unsigned char *out, const unsigned char *in, const unsigned char xor_with, const size_t length) { | 105 | static inline void php_hash_string_xor_char(unsigned char *out, const unsigned char *in, const unsigned char xor_with, const size_t length) { |
| 105 | size_t i; | 106 | size_t i; |
| @@ -112,7 +113,11 @@ static inline void php_hash_hmac_prep_key(unsigned char *K, const php_hash_ops * | |||
| 112 | memset(K, 0, ops->block_size); | 113 | memset(K, 0, ops->block_size); |
| 113 | if (key_len > ops->block_size) { | 114 | if (key_len > ops->block_size) { |
| 114 | /* Reduce the key first */ | 115 | /* Reduce the key first */ |
| 116 | #if PHP_VERSION_ID < 80100 | ||
| 115 | ops->hash_init(context); | 117 | ops->hash_init(context); |
| 118 | #else | ||
| 119 | ops->hash_init(context, NULL); | ||
| 120 | #endif | ||
| 116 | ops->hash_update(context, key, key_len); | 121 | ops->hash_update(context, key, key_len); |
| 117 | ops->hash_final(K, context); | 122 | ops->hash_final(K, context); |
| 118 | } else { | 123 | } else { |
| @@ -123,7 +128,11 @@ static inline void php_hash_hmac_prep_key(unsigned char *K, const php_hash_ops * | |||
| 123 | } | 128 | } |
| 124 | 129 | ||
| 125 | static inline void php_hash_hmac_round(unsigned char *final, const php_hash_ops *ops, void *context, const unsigned char *key, const unsigned char *data, const zend_long data_size) { | 130 | static inline void php_hash_hmac_round(unsigned char *final, const php_hash_ops *ops, void *context, const unsigned char *key, const unsigned char *data, const zend_long data_size) { |
| 131 | #if PHP_VERSION_ID < 80100 | ||
| 126 | ops->hash_init(context); | 132 | ops->hash_init(context); |
| 133 | #else | ||
| 134 | ops->hash_init(context, NULL); | ||
| 135 | #endif | ||
| 127 | ops->hash_update(context, key, ops->block_size); | 136 | ops->hash_update(context, key, ops->block_size); |
| 128 | ops->hash_update(context, data, data_size); | 137 | ops->hash_update(context, data, data_size); |
| 129 | ops->hash_final(final, context); | 138 | ops->hash_final(final, context); |
