summaryrefslogtreecommitdiff
path: root/src/sp_disabled_functions.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sp_disabled_functions.c')
-rw-r--r--src/sp_disabled_functions.c48
1 files changed, 45 insertions, 3 deletions
diff --git a/src/sp_disabled_functions.c b/src/sp_disabled_functions.c
index b3e5cbc..b465a30 100644
--- a/src/sp_disabled_functions.c
+++ b/src/sp_disabled_functions.c
@@ -31,6 +31,35 @@ static zend_always_inline char* get_complete_function_path(
31 return complete_path_function; 31 return complete_path_function;
32} 32}
33 33
34static bool is_functions_list_matching(zend_execute_data *execute_data, sp_node_t *functions_list) {
35 zend_execute_data *orig_execute_data, *current;
36 orig_execute_data = current = execute_data;
37 sp_node_t *it = functions_list;
38
39 while (current) {
40 if (it == NULL) { // every function in the list matched, we've got a match!
41 return true;
42 }
43
44 EG(current_execute_data) = current;
45
46 char *complete_path_function = get_complete_function_path(current);
47 int match = strcmp(((char*)it->data), complete_path_function);
48 efree(complete_path_function);
49
50 if (0 == match) {
51 it = it->next;
52 current = current->prev_execute_data;
53 } else {
54 EG(current_execute_data) = orig_execute_data;
55 return false;
56 }
57 }
58
59 EG(current_execute_data) = orig_execute_data;
60 return false;
61}
62
34static bool is_local_var_matching(zend_execute_data *execute_data, const sp_disabled_function *const config_node) { 63static bool is_local_var_matching(zend_execute_data *execute_data, const sp_disabled_function *const config_node) {
35 zend_execute_data *orig_execute_data = execute_data; 64 zend_execute_data *orig_execute_data = execute_data;
36 65
@@ -100,7 +129,14 @@ bool should_disable(zend_execute_data* execute_data) {
100 goto next; 129 goto next;
101 } 130 }
102 131
103 if (config_node->function) { /* Litteral match against the function name. */ 132 /* The order matters, since when we have `config_node->functions_list`,
133 we also do have `config_node->function` */
134 if (config_node->functions_list) {
135 if (false ==
136 is_functions_list_matching(execute_data, config_node->functions_list)) {
137 goto next;
138 }
139 } else if (config_node->function) { /* Litteral match against the function name. */
104 if (0 != strcmp(config_node->function, complete_path_function)) { 140 if (0 != strcmp(config_node->function, complete_path_function)) {
105 goto next; 141 goto next;
106 } 142 }
@@ -110,6 +146,7 @@ bool should_disable(zend_execute_data* execute_data) {
110 goto next; 146 goto next;
111 } 147 }
112 } 148 }
149
113 if (config_node->var) { 150 if (config_node->var) {
114 if (false == is_local_var_matching(execute_data, config_node)) { 151 if (false == is_local_var_matching(execute_data, config_node)) {
115 goto next; 152 goto next;
@@ -207,8 +244,13 @@ bool should_disable(zend_execute_data* execute_data) {
207 goto allow; 244 goto allow;
208 } 245 }
209 246
210 sp_log_disable(complete_path_function, arg_name, arg_value_str, 247 if (config_node->functions_list) {
211 config_node); 248 sp_log_disable(config_node->function, arg_name, arg_value_str,
249 config_node);
250 } else {
251 sp_log_disable(complete_path_function, arg_name, arg_value_str,
252 config_node);
253 }
212 if (true == config_node->simulation) { 254 if (true == config_node->simulation) {
213 goto next; 255 goto next;
214 } else { // We've got a match, the function won't be executed 256 } else { // We've got a match, the function won't be executed