diff options
| author | jvoisin | 2021-01-30 21:19:29 +0100 |
|---|---|---|
| committer | jvoisin | 2021-01-30 21:19:29 +0100 |
| commit | 467f965bf178b1c4d60ddac87af14718f6013bab (patch) | |
| tree | ca0b616534c2ab2513a99112c213cd87d116f3dd | |
| parent | 484bb5613be54cc37d7b2136eca9e2f4e3eb6f1a (diff) | |
Improve a bit type diversity
| -rw-r--r-- | src/sp_disabled_functions.c | 17 | ||||
| -rw-r--r-- | src/sp_utils.c | 8 | ||||
| -rw-r--r-- | src/sp_utils.h | 2 |
3 files changed, 12 insertions, 15 deletions
diff --git a/src/sp_disabled_functions.c b/src/sp_disabled_functions.c index 41c9f23..6a559c8 100644 --- a/src/sp_disabled_functions.c +++ b/src/sp_disabled_functions.c | |||
| @@ -532,13 +532,13 @@ static int hook_functions_regexp(const sp_list_node* config) { | |||
| 532 | return SUCCESS; | 532 | return SUCCESS; |
| 533 | } | 533 | } |
| 534 | 534 | ||
| 535 | static int hook_functions(HashTable* to_hook_ht, HashTable* hooked_ht) { | 535 | static void hook_functions(HashTable* to_hook_ht, HashTable* hooked_ht) { |
| 536 | zend_string* key; | 536 | zend_string* key; |
| 537 | zval* value; | 537 | zval* value; |
| 538 | 538 | ||
| 539 | ZEND_HASH_FOREACH_STR_KEY_VAL(to_hook_ht, key, value) { | 539 | ZEND_HASH_FOREACH_STR_KEY_VAL(to_hook_ht, key, value) { |
| 540 | bool hooked = !HOOK_FUNCTION(ZSTR_VAL(key), disabled_functions_hook, | 540 | bool hooked = HOOK_FUNCTION(ZSTR_VAL(key), disabled_functions_hook, |
| 541 | PHP_FN(check_disabled_function)); | 541 | PHP_FN(check_disabled_function)); |
| 542 | bool is_builtin = | 542 | bool is_builtin = |
| 543 | check_is_builtin_name(((sp_list_node*)Z_PTR_P(value))->data); | 543 | check_is_builtin_name(((sp_list_node*)Z_PTR_P(value))->data); |
| 544 | if (hooked || is_builtin) { | 544 | if (hooked || is_builtin) { |
| @@ -547,7 +547,6 @@ static int hook_functions(HashTable* to_hook_ht, HashTable* hooked_ht) { | |||
| 547 | } | 547 | } |
| 548 | } | 548 | } |
| 549 | ZEND_HASH_FOREACH_END(); | 549 | ZEND_HASH_FOREACH_END(); |
| 550 | return SUCCESS; | ||
| 551 | } | 550 | } |
| 552 | 551 | ||
| 553 | ZEND_FUNCTION(eval_blacklist_callback) { | 552 | ZEND_FUNCTION(eval_blacklist_callback) { |
| @@ -595,13 +594,11 @@ int hook_disabled_functions(void) { | |||
| 595 | 594 | ||
| 596 | int ret = SUCCESS; | 595 | int ret = SUCCESS; |
| 597 | 596 | ||
| 598 | ret |= | 597 | hook_functions(SNUFFLEUPAGUS_G(config).config_disabled_functions, |
| 599 | hook_functions(SNUFFLEUPAGUS_G(config).config_disabled_functions, | 598 | SNUFFLEUPAGUS_G(config).config_disabled_functions_hooked); |
| 600 | SNUFFLEUPAGUS_G(config).config_disabled_functions_hooked); | ||
| 601 | 599 | ||
| 602 | ret |= hook_functions( | 600 | hook_functions(SNUFFLEUPAGUS_G(config).config_disabled_functions_ret, |
| 603 | SNUFFLEUPAGUS_G(config).config_disabled_functions_ret, | 601 | SNUFFLEUPAGUS_G(config).config_disabled_functions_ret_hooked); |
| 604 | SNUFFLEUPAGUS_G(config).config_disabled_functions_ret_hooked); | ||
| 605 | 602 | ||
| 606 | ret |= hook_functions_regexp( | 603 | ret |= hook_functions_regexp( |
| 607 | SNUFFLEUPAGUS_G(config) | 604 | SNUFFLEUPAGUS_G(config) |
diff --git a/src/sp_utils.c b/src/sp_utils.c index 147cc46..a7a3d27 100644 --- a/src/sp_utils.c +++ b/src/sp_utils.c | |||
| @@ -394,10 +394,10 @@ bool sp_match_array_value(const zval* arr, const zend_string* to_match, | |||
| 394 | return false; | 394 | return false; |
| 395 | } | 395 | } |
| 396 | 396 | ||
| 397 | int hook_function(const char* original_name, HashTable* hook_table, | 397 | bool hook_function(const char* original_name, HashTable* hook_table, |
| 398 | zif_handler new_function) { | 398 | zif_handler new_function) { |
| 399 | zend_internal_function* func; | 399 | zend_internal_function* func; |
| 400 | bool ret = FAILURE; | 400 | bool ret = false; |
| 401 | 401 | ||
| 402 | /* The `mb` module likes to hook functions, like strlen->mb_strlen, | 402 | /* The `mb` module likes to hook functions, like strlen->mb_strlen, |
| 403 | * so we have to hook both of them. */ | 403 | * so we have to hook both of them. */ |
| @@ -416,7 +416,7 @@ int hook_function(const char* original_name, HashTable* hook_table, | |||
| 416 | // LCOV_EXCL_STOP | 416 | // LCOV_EXCL_STOP |
| 417 | } | 417 | } |
| 418 | func->handler = new_function; | 418 | func->handler = new_function; |
| 419 | ret = SUCCESS; | 419 | ret = true; |
| 420 | } | 420 | } |
| 421 | } | 421 | } |
| 422 | 422 | ||
diff --git a/src/sp_utils.h b/src/sp_utils.h index a883d6d..081f786 100644 --- a/src/sp_utils.h +++ b/src/sp_utils.h | |||
| @@ -72,7 +72,7 @@ void sp_log_disable(const char *restrict, const char *restrict, | |||
| 72 | const zend_string *restrict, const sp_disabled_function *); | 72 | const zend_string *restrict, const sp_disabled_function *); |
| 73 | void sp_log_disable_ret(const char *restrict, const zend_string *restrict, | 73 | void sp_log_disable_ret(const char *restrict, const zend_string *restrict, |
| 74 | const sp_disabled_function *); | 74 | const sp_disabled_function *); |
| 75 | int hook_function(const char *, HashTable *, zif_handler); | 75 | bool hook_function(const char *, HashTable *, zif_handler); |
| 76 | int hook_regexp(const sp_pcre *, HashTable *, zif_handler); | 76 | int hook_regexp(const sp_pcre *, HashTable *, zif_handler); |
| 77 | bool check_is_in_eval_whitelist(const zend_string *const function_name); | 77 | bool check_is_in_eval_whitelist(const zend_string *const function_name); |
| 78 | int sp_log_request(const zend_string *restrict folder, | 78 | int sp_log_request(const zend_string *restrict folder, |
