summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/sp_disabled_functions.c17
-rw-r--r--src/sp_utils.c8
-rw-r--r--src/sp_utils.h2
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
535static int hook_functions(HashTable* to_hook_ht, HashTable* hooked_ht) { 535static 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
553ZEND_FUNCTION(eval_blacklist_callback) { 552ZEND_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
397int hook_function(const char* original_name, HashTable* hook_table, 397bool 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 *);
73void sp_log_disable_ret(const char *restrict, const zend_string *restrict, 73void sp_log_disable_ret(const char *restrict, const zend_string *restrict,
74 const sp_disabled_function *); 74 const sp_disabled_function *);
75int hook_function(const char *, HashTable *, zif_handler); 75bool hook_function(const char *, HashTable *, zif_handler);
76int hook_regexp(const sp_pcre *, HashTable *, zif_handler); 76int hook_regexp(const sp_pcre *, HashTable *, zif_handler);
77bool check_is_in_eval_whitelist(const zend_string *const function_name); 77bool check_is_in_eval_whitelist(const zend_string *const function_name);
78int sp_log_request(const zend_string *restrict folder, 78int sp_log_request(const zend_string *restrict folder,