summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjvoisin2017-11-29 16:02:08 +0100
committerjvoisin2017-11-29 16:02:08 +0100
commit640a74361c437011c07593b685e5f9964ad5f74a (patch)
treefb10bb418b2003e20abd379e084d3d0fdef6b2ef /src
parent24d414503e9831ae9a7a7871e93fdd8430911466 (diff)
Add a comment, and improve a bit the performances wrt. vpatch
Move the cheapest tests above the expensive ones
Diffstat (limited to 'src')
-rw-r--r--src/sp_disabled_functions.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/sp_disabled_functions.c b/src/sp_disabled_functions.c
index 4e52431..6c180aa 100644
--- a/src/sp_disabled_functions.c
+++ b/src/sp_disabled_functions.c
@@ -147,13 +147,15 @@ static bool is_param_matching(zend_execute_data* execute_data,
147 } 147 }
148 148
149 if (builtin_name) { 149 if (builtin_name) {
150 // we are matching on a builtin param, but for PHP, it's not the same a 150 /* We're matching on a language construct (here named "builtin"),
151 // function param 151 * and they can only take a single argument, but PHP considers them
152 * differently than functions arguments. */
152 *arg_name = builtin_param_name; 153 *arg_name = builtin_param_name;
153 *arg_value_str = builtin_param; 154 *arg_value_str = builtin_param;
154 return sp_match_value(builtin_param, config_node->value, 155 return sp_match_value(builtin_param, config_node->value,
155 config_node->value_r); 156 config_node->value_r);
156 } else { 157 } else {
158 // We're matching on a function (and not a language construct)
157 for (; i < nb_param; i++) { 159 for (; i < nb_param; i++) {
158 if (ZEND_USER_CODE(execute_data->func->type)) { // yay consistency 160 if (ZEND_USER_CODE(execute_data->func->type)) { // yay consistency
159 *arg_name = ZSTR_VAL(execute_data->func->common.arg_info[i].name); 161 *arg_name = ZSTR_VAL(execute_data->func->common.arg_info[i].name);
@@ -246,8 +248,7 @@ bool should_disable(zend_execute_data* execute_data, const char* builtin_name,
246 config_node->functions_list)) { 248 config_node->functions_list)) {
247 goto next; 249 goto next;
248 } 250 }
249 } else if (config_node 251 } else if (config_node->function) {
250 ->function) { /* Litteral match against the function name. */
251 if (0 != strcmp(config_node->function, complete_path_function)) { 252 if (0 != strcmp(config_node->function, complete_path_function)) {
252 goto next; 253 goto next;
253 } 254 }
@@ -258,8 +259,8 @@ bool should_disable(zend_execute_data* execute_data, const char* builtin_name,
258 } 259 }
259 } 260 }
260 261
261 if (config_node->var) { 262 if (config_node->line) {
262 if (false == is_local_var_matching(execute_data, config_node)) { 263 if (config_node->line != zend_get_executed_lineno()) {
263 goto next; 264 goto next;
264 } 265 }
265 } 266 }
@@ -275,6 +276,17 @@ bool should_disable(zend_execute_data* execute_data, const char* builtin_name,
275 } 276 }
276 } 277 }
277 278
279 if (client_ip && config_node->cidr &&
280 (false == cidr_match(client_ip, config_node->cidr))) {
281 goto next;
282 }
283
284 if (config_node->var) {
285 if (false == is_local_var_matching(execute_data, config_node)) {
286 goto next;
287 }
288 }
289
278 if (config_node->hash) { 290 if (config_node->hash) {
279 if ('\0' == current_file_hash[0]) { 291 if ('\0' == current_file_hash[0]) {
280 compute_hash(current_filename, current_file_hash); 292 compute_hash(current_filename, current_file_hash);
@@ -284,17 +296,6 @@ bool should_disable(zend_execute_data* execute_data, const char* builtin_name,
284 } 296 }
285 } 297 }
286 298
287 if (config_node->line) {
288 if (config_node->line != zend_get_executed_lineno()) {
289 goto next;
290 }
291 }
292
293 if (client_ip && config_node->cidr &&
294 (false == cidr_match(client_ip, config_node->cidr))) {
295 goto next;
296 }
297
298 /* Check if we filter on parameter value*/ 299 /* Check if we filter on parameter value*/
299 if (config_node->param || config_node->r_param || 300 if (config_node->param || config_node->r_param ||
300 (config_node->pos != -1)) { 301 (config_node->pos != -1)) {