diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/sp_disabled_functions.c | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/src/sp_disabled_functions.c b/src/sp_disabled_functions.c index 4c85dec..216f696 100644 --- a/src/sp_disabled_functions.c +++ b/src/sp_disabled_functions.c | |||
| @@ -259,7 +259,7 @@ void should_disable_ht(zend_execute_data* execute_data, | |||
| 259 | current_filename = zend_string_init(tmp, strlen(tmp), 0); | 259 | current_filename = zend_string_init(tmp, strlen(tmp), 0); |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | ht_entry = zend_hash_str_find_ptr(ht, function_name, strlen(function_name)); | 262 | ht_entry = zend_hash_str_find_ptr(ht, VAR_AND_LEN(function_name)); |
| 263 | 263 | ||
| 264 | if (ht_entry) { | 264 | if (ht_entry) { |
| 265 | should_disable(execute_data, function_name, builtin_param, | 265 | should_disable(execute_data, function_name, builtin_param, |
| @@ -279,29 +279,24 @@ static void should_disable(zend_execute_data* execute_data, | |||
| 279 | const sp_list_node* config, | 279 | const sp_list_node* config, |
| 280 | const zend_string* current_filename) { | 280 | const zend_string* current_filename) { |
| 281 | char current_file_hash[SHA256_SIZE * 2 + 1] = {0}; | 281 | char current_file_hash[SHA256_SIZE * 2 + 1] = {0}; |
| 282 | // sp_log_debug("%s %s %s", complete_function_path, builtin_param, builtin_param_name); | ||
| 283 | 282 | ||
| 284 | while (config) { | 283 | while (config) { |
| 285 | sp_disabled_function const* const config_node = | 284 | sp_disabled_function const* const config_node = (sp_disabled_function*)(config->data); |
| 286 | (sp_disabled_function*)(config->data); | ||
| 287 | const char* arg_name = NULL; | 285 | const char* arg_name = NULL; |
| 288 | const zend_string* arg_value_str = NULL; | 286 | const zend_string* arg_value_str = NULL; |
| 289 | 287 | ||
| 290 | /* The order matters, since when we have `config_node->functions_list`, | 288 | /* The order matters, since when we have `config_node->functions_list`, |
| 291 | we also do have `config_node->function` */ | 289 | we also do have `config_node->function` */ |
| 292 | if (config_node->functions_list) { | 290 | if (config_node->functions_list) { |
| 293 | if (false == is_functions_list_matching(execute_data, | 291 | if (false == is_functions_list_matching(execute_data, config_node->functions_list)) { |
| 294 | config_node->functions_list)) { | ||
| 295 | goto next; | 292 | goto next; |
| 296 | } | 293 | } |
| 297 | } else if (config_node->function) { | 294 | } else if (config_node->function) { |
| 298 | if (0 != | 295 | if (0 != strcmp(ZSTR_VAL(config_node->function), complete_function_path)) { |
| 299 | strcmp(ZSTR_VAL(config_node->function), complete_function_path)) { | ||
| 300 | goto next; // LCOV_EXCL_LINE | 296 | goto next; // LCOV_EXCL_LINE |
| 301 | } | 297 | } |
| 302 | } else if (config_node->r_function) { | 298 | } else if (config_node->r_function) { |
| 303 | if (false == sp_is_regexp_matching(config_node->r_function, | 299 | if (false == sp_is_regexp_matching(config_node->r_function, complete_function_path)) { |
| 304 | complete_function_path)) { | ||
| 305 | goto next; | 300 | goto next; |
| 306 | } | 301 | } |
| 307 | } | 302 | } |
| @@ -313,8 +308,7 @@ static void should_disable(zend_execute_data* execute_data, | |||
| 313 | } | 308 | } |
| 314 | 309 | ||
| 315 | if (config_node->filename || config_node->r_filename) { | 310 | if (config_node->filename || config_node->r_filename) { |
| 316 | zend_execute_data* ex = | 311 | zend_execute_data* ex = is_file_matching(execute_data, config_node, current_filename); |
| 317 | is_file_matching(execute_data, config_node, current_filename); | ||
| 318 | if (!ex) { | 312 | if (!ex) { |
| 319 | goto next; | 313 | goto next; |
| 320 | } | 314 | } |
| @@ -337,8 +331,7 @@ static void should_disable(zend_execute_data* execute_data, | |||
| 337 | if ('\0' == current_file_hash[0]) { | 331 | if ('\0' == current_file_hash[0]) { |
| 338 | compute_hash(ZSTR_VAL(current_filename), current_file_hash); | 332 | compute_hash(ZSTR_VAL(current_filename), current_file_hash); |
| 339 | } | 333 | } |
| 340 | if (0 != strncmp(current_file_hash, ZSTR_VAL(config_node->hash), | 334 | if (0 != strncmp(current_file_hash, ZSTR_VAL(config_node->hash), SHA256_SIZE)) { |
| 341 | SHA256_SIZE)) { | ||
| 342 | goto next; | 335 | goto next; |
| 343 | } | 336 | } |
| 344 | } | 337 | } |
| @@ -359,9 +352,7 @@ static void should_disable(zend_execute_data* execute_data, | |||
| 359 | "Snuffleupagus doesn't support variadic functions yet, sorry. " | 352 | "Snuffleupagus doesn't support variadic functions yet, sorry. " |
| 360 | "Check https://github.com/jvoisin/snuffleupagus/issues/164 for " | 353 | "Check https://github.com/jvoisin/snuffleupagus/issues/164 for " |
| 361 | "details."); | 354 | "details."); |
| 362 | } else if (false == is_param_matching( | 355 | } else if (false == is_param_matching(execute_data, config_node, builtin_param, builtin_param_name, &arg_name, &arg_value_str)) { |
| 363 | execute_data, config_node, builtin_param, builtin_param_name, | ||
| 364 | &arg_name, &arg_value_str)) { | ||
| 365 | goto next; | 356 | goto next; |
| 366 | } | 357 | } |
| 367 | } | 358 | } |
| @@ -372,11 +363,9 @@ static void should_disable(zend_execute_data* execute_data, | |||
| 372 | } | 363 | } |
| 373 | 364 | ||
| 374 | if (config_node->functions_list) { | 365 | if (config_node->functions_list) { |
| 375 | sp_log_disable(ZSTR_VAL(config_node->function), arg_name, arg_value_str, | 366 | sp_log_disable(ZSTR_VAL(config_node->function), arg_name, arg_value_str, config_node); |
| 376 | config_node); | ||
| 377 | } else { | 367 | } else { |
| 378 | sp_log_disable(complete_function_path, arg_name, arg_value_str, | 368 | sp_log_disable(complete_function_path, arg_name, arg_value_str, config_node); |
| 379 | config_node); | ||
| 380 | } | 369 | } |
| 381 | 370 | ||
| 382 | next: | 371 | next: |
| @@ -480,10 +469,9 @@ ZEND_FUNCTION(check_disabled_function) { | |||
| 480 | 469 | ||
| 481 | should_disable_ht(execute_data, current_function_name, NULL, NULL, SPCFG(disabled_functions_reg).disabled_functions, SPCFG(disabled_functions_hooked)); | 470 | should_disable_ht(execute_data, current_function_name, NULL, NULL, SPCFG(disabled_functions_reg).disabled_functions, SPCFG(disabled_functions_hooked)); |
| 482 | 471 | ||
| 483 | orig_handler = zend_hash_str_find_ptr( | 472 | orig_handler = zend_hash_str_find_ptr(SPG(disabled_functions_hook), VAR_AND_LEN(current_function_name)); |
| 484 | SPG(disabled_functions_hook), current_function_name, | ||
| 485 | strlen(current_function_name)); | ||
| 486 | orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); | 473 | orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); |
| 474 | |||
| 487 | should_drop_on_ret_ht(return_value, current_function_name, SPCFG(disabled_functions_reg_ret).disabled_functions, SPCFG(disabled_functions_ret_hooked), execute_data); | 475 | should_drop_on_ret_ht(return_value, current_function_name, SPCFG(disabled_functions_reg_ret).disabled_functions, SPCFG(disabled_functions_ret_hooked), execute_data); |
| 488 | } | 476 | } |
| 489 | 477 | ||
