summaryrefslogtreecommitdiff
path: root/src/sp_disabled_functions.c
diff options
context:
space:
mode:
authorxXx-caillou-xXx2018-08-30 14:43:58 +0200
committerjvoisin2018-08-30 12:43:58 +0000
commitf61a4772bfc33e08e7b06250e2f0f640bcae875f (patch)
tree2c26573cdd6ffa9eed1a46291660d82611154eb0 /src/sp_disabled_functions.c
parentdcc64e0f1530fbe5d528873977199ceeb715305d (diff)
Match on ret improvements
This commit does two things: - Implement matching on calltraces for ret - Implement matching on ret of user functions if the return value is not used.
Diffstat (limited to '')
-rw-r--r--src/sp_disabled_functions.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/sp_disabled_functions.c b/src/sp_disabled_functions.c
index 842b15c..379ed75 100644
--- a/src/sp_disabled_functions.c
+++ b/src/sp_disabled_functions.c
@@ -403,8 +403,9 @@ allow:
403 return false; 403 return false;
404} 404}
405 405
406bool should_drop_on_ret_ht(zval* return_value, const char* function_name, 406bool should_drop_on_ret_ht(const zval* return_value, const char* function_name,
407 const sp_list_node* config, const HashTable* ht) { 407 const sp_list_node* config, const HashTable* ht,
408 zend_execute_data* execute_data) {
408 const sp_list_node* ht_entry = NULL; 409 const sp_list_node* ht_entry = NULL;
409 bool ret = false; 410 bool ret = false;
410 411
@@ -414,17 +415,19 @@ bool should_drop_on_ret_ht(zval* return_value, const char* function_name,
414 415
415 ht_entry = zend_hash_str_find_ptr(ht, function_name, strlen(function_name)); 416 ht_entry = zend_hash_str_find_ptr(ht, function_name, strlen(function_name));
416 417
417 if (ht_entry && should_drop_on_ret(return_value, ht_entry, function_name)) { 418 if (ht_entry && should_drop_on_ret(return_value, ht_entry, function_name,
419 execute_data)) {
418 ret = true; 420 ret = true;
419 } else if (config && config->data) { 421 } else if (config && config->data) {
420 ret = should_drop_on_ret(return_value, config, function_name); 422 ret = should_drop_on_ret(return_value, config, function_name, execute_data);
421 } 423 }
422 424
423 return ret; 425 return ret;
424} 426}
425 427
426bool should_drop_on_ret(zval* return_value, const sp_list_node* config, 428bool should_drop_on_ret(const zval* return_value, const sp_list_node* config,
427 const char* complete_function_path) { 429 const char* complete_function_path,
430 zend_execute_data* execute_data) {
428 const char* current_filename = zend_get_executed_filename(TSRMLS_C); 431 const char* current_filename = zend_get_executed_filename(TSRMLS_C);
429 char current_file_hash[SHA256_SIZE * 2 + 1] = {0}; 432 char current_file_hash[SHA256_SIZE * 2 + 1] = {0};
430 bool match_type = false, match_value = false; 433 bool match_type = false, match_value = false;
@@ -436,7 +439,12 @@ bool should_drop_on_ret(zval* return_value, const sp_list_node* config,
436 439
437 assert(config_node->function || config_node->r_function); 440 assert(config_node->function || config_node->r_function);
438 441
439 if (config_node->function) { 442 if (config_node->functions_list) {
443 if (false == is_functions_list_matching(execute_data,
444 config_node->functions_list)) {
445 goto next;
446 }
447 } else if (config_node->function) {
440 if (0 != 448 if (0 !=
441 strcmp(ZSTR_VAL(config_node->function), complete_function_path)) { 449 strcmp(ZSTR_VAL(config_node->function), complete_function_path)) {
442 goto next; 450 goto next;
@@ -513,7 +521,8 @@ ZEND_FUNCTION(check_disabled_function) {
513 return_value, current_function_name, 521 return_value, current_function_name,
514 SNUFFLEUPAGUS_G(config) 522 SNUFFLEUPAGUS_G(config)
515 .config_disabled_functions_reg_ret->disabled_functions, 523 .config_disabled_functions_reg_ret->disabled_functions,
516 SNUFFLEUPAGUS_G(config).config_disabled_functions_ret_hooked)) { 524 SNUFFLEUPAGUS_G(config).config_disabled_functions_ret_hooked,
525 execute_data)) {
517 sp_terminate(); 526 sp_terminate();
518 } 527 }
519} 528}