diff options
| author | Remi Collet | 2018-09-03 15:38:51 +0200 |
|---|---|---|
| committer | jvoisin | 2018-09-03 13:38:51 +0000 |
| commit | 499a81914597f156fe9a67e47e3baf82a0af4bde (patch) | |
| tree | 23630733f4b892d362217cb5c8840d268d03c7c1 /src | |
| parent | c947eb5378f894b154bdd33588f4bfb470075fe8 (diff) | |
Fix #241 segfault on 32-bit related to bad protype (#242)
This should close #241
Diffstat (limited to 'src')
| -rw-r--r-- | src/php_snuffleupagus.h | 5 | ||||
| -rw-r--r-- | src/sp_disabled_functions.c | 4 | ||||
| -rw-r--r-- | src/sp_harden_rand.c | 4 | ||||
| -rw-r--r-- | src/sp_sloppy.c | 4 | ||||
| -rw-r--r-- | src/sp_unserialize.c | 4 | ||||
| -rw-r--r-- | src/sp_utils.c | 6 | ||||
| -rw-r--r-- | src/sp_utils.h | 6 | ||||
| -rw-r--r-- | src/sp_wrapper.c | 2 |
8 files changed, 19 insertions, 16 deletions
diff --git a/src/php_snuffleupagus.h b/src/php_snuffleupagus.h index bc927a0..0bdf602 100644 --- a/src/php_snuffleupagus.h +++ b/src/php_snuffleupagus.h | |||
| @@ -25,6 +25,11 @@ | |||
| 25 | #include "zend_string.h" | 25 | #include "zend_string.h" |
| 26 | #include "zend_extensions.h" | 26 | #include "zend_extensions.h" |
| 27 | 27 | ||
| 28 | /* Compatibility */ | ||
| 29 | #if PHP_VERSION_ID < 70200 | ||
| 30 | typedef void (*zif_handler)(INTERNAL_FUNCTION_PARAMETERS); | ||
| 31 | #endif | ||
| 32 | |||
| 28 | #include "sp_pcre_compat.h" | 33 | #include "sp_pcre_compat.h" |
| 29 | #include "sp_list.h" | 34 | #include "sp_list.h" |
| 30 | #include "sp_tree.h" | 35 | #include "sp_tree.h" |
diff --git a/src/sp_disabled_functions.c b/src/sp_disabled_functions.c index 835776b..b8ec845 100644 --- a/src/sp_disabled_functions.c +++ b/src/sp_disabled_functions.c | |||
| @@ -501,7 +501,7 @@ bool should_drop_on_ret(const zval* return_value, const sp_list_node* config, | |||
| 501 | } | 501 | } |
| 502 | 502 | ||
| 503 | ZEND_FUNCTION(check_disabled_function) { | 503 | ZEND_FUNCTION(check_disabled_function) { |
| 504 | void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS); | 504 | zif_handler orig_handler; |
| 505 | const char* current_function_name = get_active_function_name(TSRMLS_C); | 505 | const char* current_function_name = get_active_function_name(TSRMLS_C); |
| 506 | 506 | ||
| 507 | if (true == should_disable_ht( | 507 | if (true == should_disable_ht( |
| @@ -566,7 +566,7 @@ static int hook_functions(HashTable* to_hook_ht, HashTable* hooked_ht) { | |||
| 566 | } | 566 | } |
| 567 | 567 | ||
| 568 | ZEND_FUNCTION(eval_blacklist_callback) { | 568 | ZEND_FUNCTION(eval_blacklist_callback) { |
| 569 | void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS); | 569 | zif_handler orig_handler; |
| 570 | const char* current_function_name = get_active_function_name(TSRMLS_C); | 570 | const char* current_function_name = get_active_function_name(TSRMLS_C); |
| 571 | zend_string* tmp = | 571 | zend_string* tmp = |
| 572 | zend_string_init(current_function_name, strlen(current_function_name), 0); | 572 | zend_string_init(current_function_name, strlen(current_function_name), 0); |
diff --git a/src/sp_harden_rand.c b/src/sp_harden_rand.c index 7b4e958..7ab798e 100644 --- a/src/sp_harden_rand.c +++ b/src/sp_harden_rand.c | |||
| @@ -52,7 +52,7 @@ static void random_int_wrapper(INTERNAL_FUNCTION_PARAMETERS) { | |||
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | PHP_FUNCTION(sp_rand) { | 54 | PHP_FUNCTION(sp_rand) { |
| 55 | void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS); | 55 | zif_handler orig_handler; |
| 56 | 56 | ||
| 57 | /* call the original `rand` function, | 57 | /* call the original `rand` function, |
| 58 | * since we might no be the only ones to hook it*/ | 58 | * since we might no be the only ones to hook it*/ |
| @@ -64,7 +64,7 @@ PHP_FUNCTION(sp_rand) { | |||
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | PHP_FUNCTION(sp_mt_rand) { | 66 | PHP_FUNCTION(sp_mt_rand) { |
| 67 | void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS); | 67 | zif_handler orig_handler; |
| 68 | 68 | ||
| 69 | /* call the original `mt_rand` function, | 69 | /* call the original `mt_rand` function, |
| 70 | * since we might no be the only ones to hook it*/ | 70 | * since we might no be the only ones to hook it*/ |
diff --git a/src/sp_sloppy.c b/src/sp_sloppy.c index 5b36026..ac0cb8a 100644 --- a/src/sp_sloppy.c +++ b/src/sp_sloppy.c | |||
| @@ -38,8 +38,8 @@ ZEND_API zend_op_array* sp_compile_file(zend_file_handle* file_handle, | |||
| 38 | 38 | ||
| 39 | static void array_handler(INTERNAL_FUNCTION_PARAMETERS, | 39 | static void array_handler(INTERNAL_FUNCTION_PARAMETERS, |
| 40 | const char *name, size_t size, | 40 | const char *name, size_t size, |
| 41 | void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS)) { | 41 | zif_handler orig_handler) { |
| 42 | void (*handler)(INTERNAL_FUNCTION_PARAMETERS); | 42 | zif_handler handler; |
| 43 | zval func_name; | 43 | zval func_name; |
| 44 | zval params[3]; | 44 | zval params[3]; |
| 45 | zval *value, *array; | 45 | zval *value, *array; |
diff --git a/src/sp_unserialize.c b/src/sp_unserialize.c index ab0139a..fb44ce4 100644 --- a/src/sp_unserialize.c +++ b/src/sp_unserialize.c | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus) | 3 | ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus) |
| 4 | 4 | ||
| 5 | PHP_FUNCTION(sp_serialize) { | 5 | PHP_FUNCTION(sp_serialize) { |
| 6 | void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS); | 6 | zif_handler orig_handler; |
| 7 | 7 | ||
| 8 | /* Call the original `serialize` function. */ | 8 | /* Call the original `serialize` function. */ |
| 9 | orig_handler = zend_hash_str_find_ptr( | 9 | orig_handler = zend_hash_str_find_ptr( |
| @@ -42,7 +42,7 @@ PHP_FUNCTION(sp_serialize) { | |||
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | PHP_FUNCTION(sp_unserialize) { | 44 | PHP_FUNCTION(sp_unserialize) { |
| 45 | void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS); | 45 | zif_handler orig_handler; |
| 46 | 46 | ||
| 47 | char *buf = NULL; | 47 | char *buf = NULL; |
| 48 | char *serialized_str = NULL; | 48 | char *serialized_str = NULL; |
diff --git a/src/sp_utils.c b/src/sp_utils.c index 970f314..8a3874c 100644 --- a/src/sp_utils.c +++ b/src/sp_utils.c | |||
| @@ -287,7 +287,7 @@ bool sp_match_array_key(const zval* zv, const zend_string* to_match, | |||
| 287 | } | 287 | } |
| 288 | } else { | 288 | } else { |
| 289 | char* idx_str = NULL; | 289 | char* idx_str = NULL; |
| 290 | spprintf(&idx_str, 0, "%lu", idx); | 290 | spprintf(&idx_str, 0, ZEND_ULONG_FMT, idx); |
| 291 | zend_string* tmp = zend_string_init(idx_str, strlen(idx_str), 0); | 291 | zend_string* tmp = zend_string_init(idx_str, strlen(idx_str), 0); |
| 292 | if (sp_match_value(tmp, to_match, rx)) { | 292 | if (sp_match_value(tmp, to_match, rx)) { |
| 293 | efree(idx_str); | 293 | efree(idx_str); |
| @@ -320,7 +320,7 @@ bool sp_match_array_value(const zval* arr, const zend_string* to_match, | |||
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | int hook_function(const char* original_name, HashTable* hook_table, | 322 | int hook_function(const char* original_name, HashTable* hook_table, |
| 323 | void (*new_function)(INTERNAL_FUNCTION_PARAMETERS)) { | 323 | zif_handler new_function) { |
| 324 | zend_internal_function* func; | 324 | zend_internal_function* func; |
| 325 | bool ret = FAILURE; | 325 | bool ret = FAILURE; |
| 326 | 326 | ||
| @@ -363,7 +363,7 @@ int hook_function(const char* original_name, HashTable* hook_table, | |||
| 363 | } | 363 | } |
| 364 | 364 | ||
| 365 | int hook_regexp(const sp_pcre* regexp, HashTable* hook_table, | 365 | int hook_regexp(const sp_pcre* regexp, HashTable* hook_table, |
| 366 | void (*new_function)(INTERNAL_FUNCTION_PARAMETERS)) { | 366 | zif_handler new_function) { |
| 367 | zend_string* key; | 367 | zend_string* key; |
| 368 | 368 | ||
| 369 | ZEND_HASH_FOREACH_STR_KEY(CG(function_table), key) | 369 | ZEND_HASH_FOREACH_STR_KEY(CG(function_table), key) |
diff --git a/src/sp_utils.h b/src/sp_utils.h index c094fac..d835905 100644 --- a/src/sp_utils.h +++ b/src/sp_utils.h | |||
| @@ -54,10 +54,8 @@ void sp_log_disable(const char *restrict, const char *restrict, | |||
| 54 | const zend_string *restrict, const sp_disabled_function *); | 54 | const zend_string *restrict, const sp_disabled_function *); |
| 55 | void sp_log_disable_ret(const char *restrict, const zend_string *restrict, | 55 | void sp_log_disable_ret(const char *restrict, const zend_string *restrict, |
| 56 | const sp_disabled_function *); | 56 | const sp_disabled_function *); |
| 57 | int hook_function(const char *, HashTable *, | 57 | int hook_function(const char *, HashTable *, zif_handler); |
| 58 | void (*)(INTERNAL_FUNCTION_PARAMETERS)); | 58 | int hook_regexp(const sp_pcre *, HashTable *, zif_handler); |
| 59 | int hook_regexp(const sp_pcre *, HashTable *, | ||
| 60 | void (*)(INTERNAL_FUNCTION_PARAMETERS)); | ||
| 61 | bool check_is_in_eval_whitelist(const zend_string *const function_name); | 59 | bool check_is_in_eval_whitelist(const zend_string *const function_name); |
| 62 | int sp_log_request(const zend_string *folder, const zend_string *text_repr, | 60 | int sp_log_request(const zend_string *folder, const zend_string *text_repr, |
| 63 | char *from); | 61 | char *from); |
diff --git a/src/sp_wrapper.c b/src/sp_wrapper.c index d9cd296..3090513 100644 --- a/src/sp_wrapper.c +++ b/src/sp_wrapper.c | |||
| @@ -45,7 +45,7 @@ void sp_disable_wrapper() { | |||
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | PHP_FUNCTION(sp_stream_wrapper_register) { | 47 | PHP_FUNCTION(sp_stream_wrapper_register) { |
| 48 | void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS); | 48 | zif_handler orig_handler; |
| 49 | zend_string *protocol_name = NULL; | 49 | zend_string *protocol_name = NULL; |
| 50 | 50 | ||
| 51 | ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_QUIET, 2, EX_NUM_ARGS()); | 51 | ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_QUIET, 2, EX_NUM_ARGS()); |
