diff options
| author | Ben Fuhrmannek | 2020-06-15 11:50:13 +0200 |
|---|---|---|
| committer | Ben Fuhrmannek | 2020-06-15 11:50:13 +0200 |
| commit | f742d9f88bf788e38bbe832f1b75e39784f024bc (patch) | |
| tree | 801ca13c8efedc1ff140b48be4087538c72a5329 /src/sp_disabled_functions.c | |
| parent | d8bf25aa20e93d366133b4550ac8304d06186ad3 (diff) | |
fixed trigger logic to parameter matching
Diffstat (limited to 'src/sp_disabled_functions.c')
| -rw-r--r-- | src/sp_disabled_functions.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/sp_disabled_functions.c b/src/sp_disabled_functions.c index c088f20..5daf068 100644 --- a/src/sp_disabled_functions.c +++ b/src/sp_disabled_functions.c | |||
| @@ -102,8 +102,8 @@ static bool is_local_var_matching( | |||
| 102 | static bool is_param_matching(zend_execute_data* execute_data, | 102 | static bool is_param_matching(zend_execute_data* execute_data, |
| 103 | sp_disabled_function const* const config_node, | 103 | sp_disabled_function const* const config_node, |
| 104 | const zend_string* builtin_param, | 104 | const zend_string* builtin_param, |
| 105 | const char** arg_name, | ||
| 106 | const char* builtin_param_name, | 105 | const char* builtin_param_name, |
| 106 | const char** arg_name, | ||
| 107 | const zend_string** arg_value_str) { | 107 | const zend_string** arg_value_str) { |
| 108 | int nb_param = ZEND_CALL_NUM_ARGS(execute_data); | 108 | int nb_param = ZEND_CALL_NUM_ARGS(execute_data); |
| 109 | int i = 0; | 109 | int i = 0; |
| @@ -313,11 +313,13 @@ static void should_disable(zend_execute_data* execute_data, | |||
| 313 | goto next; | 313 | goto next; |
| 314 | } | 314 | } |
| 315 | } | 315 | } |
| 316 | |||
| 316 | if (config_node->line) { | 317 | if (config_node->line) { |
| 317 | if (config_node->line != zend_get_executed_lineno()) { | 318 | if (config_node->line != zend_get_executed_lineno()) { |
| 318 | goto next; | 319 | goto next; |
| 319 | } | 320 | } |
| 320 | } | 321 | } |
| 322 | |||
| 321 | if (config_node->filename || config_node->r_filename) { | 323 | if (config_node->filename || config_node->r_filename) { |
| 322 | zend_execute_data* ex = | 324 | zend_execute_data* ex = |
| 323 | is_file_matching(execute_data, config_node, current_filename); | 325 | is_file_matching(execute_data, config_node, current_filename); |
| @@ -332,6 +334,7 @@ static void should_disable(zend_execute_data* execute_data, | |||
| 332 | goto next; | 334 | goto next; |
| 333 | } | 335 | } |
| 334 | } | 336 | } |
| 337 | |||
| 335 | if (config_node->var) { | 338 | if (config_node->var) { |
| 336 | if (false == is_local_var_matching(execute_data, config_node)) { | 339 | if (false == is_local_var_matching(execute_data, config_node)) { |
| 337 | goto next; | 340 | goto next; |
| @@ -350,7 +353,8 @@ static void should_disable(zend_execute_data* execute_data, | |||
| 350 | 353 | ||
| 351 | /* Check if we filter on parameter value*/ | 354 | /* Check if we filter on parameter value*/ |
| 352 | if (config_node->param || config_node->r_param || | 355 | if (config_node->param || config_node->r_param || |
| 353 | (config_node->pos != -1)) { | 356 | (config_node->pos != -1) || |
| 357 | ((config_node->r_value || config_node->value) && !config_node->var)) { | ||
| 354 | if (!builtin_param && | 358 | if (!builtin_param && |
| 355 | execute_data->func->op_array.arg_info->is_variadic) { | 359 | execute_data->func->op_array.arg_info->is_variadic) { |
| 356 | sp_log_warn( | 360 | sp_log_warn( |
| @@ -359,24 +363,12 @@ static void should_disable(zend_execute_data* execute_data, | |||
| 359 | "Check https://github.com/nbs-system/snuffleupagus/issues/164 for " | 363 | "Check https://github.com/nbs-system/snuffleupagus/issues/164 for " |
| 360 | "details."); | 364 | "details."); |
| 361 | } else if (false == is_param_matching( | 365 | } else if (false == is_param_matching( |
| 362 | execute_data, config_node, builtin_param, | 366 | execute_data, config_node, builtin_param, builtin_param_name, |
| 363 | &arg_name, builtin_param_name, &arg_value_str)) { | 367 | &arg_name, &arg_value_str)) { |
| 364 | goto next; | 368 | goto next; |
| 365 | } | 369 | } |
| 366 | } | 370 | } |
| 367 | 371 | ||
| 368 | if (config_node->r_value || config_node->value) { | ||
| 369 | if (check_is_builtin_name(config_node) && !config_node->var && | ||
| 370 | !config_node->key && !config_node->r_key && !config_node->param && | ||
| 371 | !config_node->r_param) { | ||
| 372 | if (false == is_param_matching(execute_data, config_node, builtin_param, | ||
| 373 | &arg_name, builtin_param_name, | ||
| 374 | &arg_value_str)) { | ||
| 375 | goto next; | ||
| 376 | } | ||
| 377 | } | ||
| 378 | } | ||
| 379 | |||
| 380 | /* Everything matched.*/ | 372 | /* Everything matched.*/ |
| 381 | if (true == config_node->allow) { | 373 | if (true == config_node->allow) { |
| 382 | return; | 374 | return; |
