diff options
Diffstat (limited to 'src/sp_disabled_functions.c')
| -rw-r--r-- | src/sp_disabled_functions.c | 40 |
1 files changed, 12 insertions, 28 deletions
diff --git a/src/sp_disabled_functions.c b/src/sp_disabled_functions.c index f6e06e4..2e459a9 100644 --- a/src/sp_disabled_functions.c +++ b/src/sp_disabled_functions.c | |||
| @@ -250,11 +250,10 @@ static bool check_is_builtin_name( | |||
| 250 | } | 250 | } |
| 251 | 251 | ||
| 252 | bool should_disable_ht(zend_execute_data* execute_data, | 252 | bool should_disable_ht(zend_execute_data* execute_data, |
| 253 | const char* builtin_name, | 253 | const char* function_name, |
| 254 | const zend_string* builtin_param, | 254 | const zend_string* builtin_param, |
| 255 | const char* builtin_param_name, | 255 | const char* builtin_param_name, |
| 256 | const sp_list_node* config, const HashTable* ht) { | 256 | const sp_list_node* config, const HashTable* ht) { |
| 257 | char* complete_function_path = NULL; | ||
| 258 | const sp_list_node* ht_entry = NULL; | 257 | const sp_list_node* ht_entry = NULL; |
| 259 | bool ret = false; | 258 | bool ret = false; |
| 260 | zend_string* current_filename; | 259 | zend_string* current_filename; |
| @@ -263,35 +262,24 @@ bool should_disable_ht(zend_execute_data* execute_data, | |||
| 263 | return false; | 262 | return false; |
| 264 | } | 263 | } |
| 265 | 264 | ||
| 266 | if (builtin_name) { | 265 | if (UNEXPECTED(builtin_param && !strcmp(function_name, "eval"))) { |
| 267 | complete_function_path = estrdup(builtin_name); | ||
| 268 | } else { | ||
| 269 | complete_function_path = get_complete_function_path(execute_data); | ||
| 270 | if (!complete_function_path) { | ||
| 271 | return false; | ||
| 272 | } | ||
| 273 | } | ||
| 274 | |||
| 275 | if (UNEXPECTED(builtin_param && !strcmp(complete_function_path, "eval"))) { | ||
| 276 | current_filename = get_eval_filename(zend_get_executed_filename()); | 266 | current_filename = get_eval_filename(zend_get_executed_filename()); |
| 277 | } else { | 267 | } else { |
| 278 | const char* tmp = zend_get_executed_filename(); | 268 | const char* tmp = zend_get_executed_filename(); |
| 279 | current_filename = zend_string_init(tmp, strlen(tmp), 0); | 269 | current_filename = zend_string_init(tmp, strlen(tmp), 0); |
| 280 | } | 270 | } |
| 281 | 271 | ||
| 282 | ht_entry = zend_hash_str_find_ptr(ht, complete_function_path, | 272 | ht_entry = zend_hash_str_find_ptr(ht, function_name, strlen(function_name)); |
| 283 | strlen(complete_function_path)); | ||
| 284 | 273 | ||
| 285 | if (ht_entry && | 274 | if (ht_entry && |
| 286 | should_disable(execute_data, complete_function_path, builtin_param, | 275 | should_disable(execute_data, function_name, builtin_param, |
| 287 | builtin_param_name, ht_entry, current_filename)) { | 276 | builtin_param_name, ht_entry, current_filename)) { |
| 288 | ret = true; | 277 | ret = true; |
| 289 | } else if (config && config->data) { | 278 | } else if (config && config->data) { |
| 290 | ret = should_disable(execute_data, complete_function_path, builtin_param, | 279 | ret = should_disable(execute_data, function_name, builtin_param, |
| 291 | builtin_param_name, config, current_filename); | 280 | builtin_param_name, config, current_filename); |
| 292 | } | 281 | } |
| 293 | 282 | ||
| 294 | efree(complete_function_path); | ||
| 295 | efree(current_filename); | 283 | efree(current_filename); |
| 296 | return ret; | 284 | return ret; |
| 297 | } | 285 | } |
| @@ -423,28 +411,24 @@ allow: | |||
| 423 | return false; | 411 | return false; |
| 424 | } | 412 | } |
| 425 | 413 | ||
| 426 | bool should_drop_on_ret_ht(zval* return_value, | 414 | bool should_drop_on_ret_ht(zval* return_value, const char* function_name, |
| 427 | const zend_execute_data* const execute_data, | ||
| 428 | const sp_list_node* config, const HashTable* ht) { | 415 | const sp_list_node* config, const HashTable* ht) { |
| 429 | char* complete_function_path = get_complete_function_path(execute_data); | ||
| 430 | const sp_list_node* ht_entry = NULL; | 416 | const sp_list_node* ht_entry = NULL; |
| 431 | bool ret = false; | 417 | bool ret = false; |
| 432 | 418 | ||
| 433 | if (!complete_function_path) { | 419 | if (!function_name) { |
| 434 | return ret; | 420 | return ret; |
| 435 | } | 421 | } |
| 436 | 422 | ||
| 437 | ht_entry = zend_hash_str_find_ptr(ht, complete_function_path, | 423 | ht_entry = zend_hash_str_find_ptr(ht, function_name, strlen(function_name)); |
| 438 | strlen(complete_function_path)); | ||
| 439 | 424 | ||
| 440 | if (ht_entry && | 425 | if (ht_entry && |
| 441 | should_drop_on_ret(return_value, ht_entry, complete_function_path)) { | 426 | should_drop_on_ret(return_value, ht_entry, function_name)) { |
| 442 | ret = true; | 427 | ret = true; |
| 443 | } else if (config && config->data) { | 428 | } else if (config && config->data) { |
| 444 | ret = should_drop_on_ret(return_value, config, complete_function_path); | 429 | ret = should_drop_on_ret(return_value, config, function_name); |
| 445 | } | 430 | } |
| 446 | 431 | ||
| 447 | efree(complete_function_path); | ||
| 448 | return ret; | 432 | return ret; |
| 449 | } | 433 | } |
| 450 | 434 | ||
| @@ -522,7 +506,7 @@ ZEND_FUNCTION(check_disabled_function) { | |||
| 522 | const char* current_function_name = get_active_function_name(TSRMLS_C); | 506 | const char* current_function_name = get_active_function_name(TSRMLS_C); |
| 523 | 507 | ||
| 524 | if (true == should_disable_ht( | 508 | if (true == should_disable_ht( |
| 525 | execute_data, NULL, NULL, NULL, | 509 | execute_data, current_function_name, NULL, NULL, |
| 526 | SNUFFLEUPAGUS_G(config) | 510 | SNUFFLEUPAGUS_G(config) |
| 527 | .config_disabled_functions_reg->disabled_functions, | 511 | .config_disabled_functions_reg->disabled_functions, |
| 528 | SNUFFLEUPAGUS_G(config).config_disabled_functions_hooked)) { | 512 | SNUFFLEUPAGUS_G(config).config_disabled_functions_hooked)) { |
| @@ -535,7 +519,7 @@ ZEND_FUNCTION(check_disabled_function) { | |||
| 535 | orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); | 519 | orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); |
| 536 | if (true == | 520 | if (true == |
| 537 | should_drop_on_ret_ht( | 521 | should_drop_on_ret_ht( |
| 538 | return_value, execute_data, | 522 | return_value, current_function_name, |
| 539 | SNUFFLEUPAGUS_G(config) | 523 | SNUFFLEUPAGUS_G(config) |
| 540 | .config_disabled_functions_reg_ret->disabled_functions, | 524 | .config_disabled_functions_reg_ret->disabled_functions, |
| 541 | SNUFFLEUPAGUS_G(config).config_disabled_functions_ret_hooked)) { | 525 | SNUFFLEUPAGUS_G(config).config_disabled_functions_ret_hooked)) { |
