diff options
| author | jvoisin | 2018-12-26 14:26:01 +0100 |
|---|---|---|
| committer | jvoisin | 2018-12-26 14:32:55 +0100 |
| commit | 54a24a61aadc9e33c3666a5d48ad1ac60e4178e6 (patch) | |
| tree | 44ae09a8f775d7664da657830eb5901f5187e932 | |
| parent | ae9855034610e63be9416ae4386f7a46b7a0936e (diff) | |
Document that it's not possible to hook builtins via regexp
Also bump a bit the coverage
| -rw-r--r-- | doc/source/config.rst | 4 | ||||
| -rw-r--r-- | src/sp_disabled_functions.c | 26 |
2 files changed, 13 insertions, 17 deletions
diff --git a/doc/source/config.rst b/doc/source/config.rst index 104515b..4159abe 100644 --- a/doc/source/config.rst +++ b/doc/source/config.rst | |||
| @@ -334,8 +334,8 @@ Limitations | |||
| 334 | It's currently not possible to: | 334 | It's currently not possible to: |
| 335 | 335 | ||
| 336 | - Hook every `language construct <https://secure.php.net/manual/en/reserved.keywords.php>`__, | 336 | - Hook every `language construct <https://secure.php.net/manual/en/reserved.keywords.php>`__, |
| 337 | because each of them requires a specific implementation. | 337 | because each of them requires a specific implementation. It's also not |
| 338 | - Hook on the return value of user-defined functions | 338 | possible to hook them via regular expression. |
| 339 | - Use extra-convoluted rules for matching, like ``${$A}$$B->${'}[1]``, because if you're writing | 339 | - Use extra-convoluted rules for matching, like ``${$A}$$B->${'}[1]``, because if you're writing |
| 340 | things like this, odds are that you're doing something wrong anyway. | 340 | things like this, odds are that you're doing something wrong anyway. |
| 341 | - Hooks on ``echo`` and on ``print`` are equivalent: there is no way to hook one | 341 | - Hooks on ``echo`` and on ``print`` are equivalent: there is no way to hook one |
diff --git a/src/sp_disabled_functions.c b/src/sp_disabled_functions.c index f597feb..bb22f71 100644 --- a/src/sp_disabled_functions.c +++ b/src/sp_disabled_functions.c | |||
| @@ -242,23 +242,16 @@ static zend_execute_data* is_file_matching( | |||
| 242 | #undef ITERATE | 242 | #undef ITERATE |
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | static bool check_is_builtin_name( | 245 | inline static bool check_is_builtin_name( |
| 246 | sp_disabled_function const* const config_node) { | 246 | sp_disabled_function const* const config_node) { |
| 247 | if (config_node->function) { | 247 | if (EXPECTED(config_node->function)) { |
| 248 | return (zend_string_equals_literal(config_node->function, "include") || | 248 | return (zend_string_equals_literal(config_node->function, "include") || |
| 249 | zend_string_equals_literal(config_node->function, "include_once") || | 249 | zend_string_equals_literal(config_node->function, "include_once") || |
| 250 | zend_string_equals_literal(config_node->function, "require") || | 250 | zend_string_equals_literal(config_node->function, "require") || |
| 251 | zend_string_equals_literal(config_node->function, "require_once") || | 251 | zend_string_equals_literal(config_node->function, "require_once") || |
| 252 | zend_string_equals_literal(config_node->function, "echo")); | 252 | zend_string_equals_literal(config_node->function, "echo")); |
| 253 | } | 253 | } |
| 254 | if (config_node->r_function) { | 254 | return false; // LCOV_EXCL_LINE |
| 255 | return (sp_is_regexp_matching(config_node->r_function, "include") || | ||
| 256 | sp_is_regexp_matching(config_node->r_function, "include_once") || | ||
| 257 | sp_is_regexp_matching(config_node->r_function, "require") || | ||
| 258 | sp_is_regexp_matching(config_node->r_function, "require_once") || | ||
| 259 | sp_is_regexp_matching(config_node->r_function, "echo")); | ||
| 260 | } | ||
| 261 | return false; | ||
| 262 | } | 255 | } |
| 263 | 256 | ||
| 264 | void should_disable_ht(zend_execute_data* execute_data, | 257 | void should_disable_ht(zend_execute_data* execute_data, |
| @@ -317,7 +310,7 @@ static void should_disable(zend_execute_data* execute_data, | |||
| 317 | } else if (config_node->function) { | 310 | } else if (config_node->function) { |
| 318 | if (0 != | 311 | if (0 != |
| 319 | strcmp(ZSTR_VAL(config_node->function), complete_function_path)) { | 312 | strcmp(ZSTR_VAL(config_node->function), complete_function_path)) { |
| 320 | goto next; | 313 | goto next; // LCOV_EXCL_LINE |
| 321 | } | 314 | } |
| 322 | } else if (config_node->r_function) { | 315 | } else if (config_node->r_function) { |
| 323 | if (false == sp_is_regexp_matching(config_node->r_function, | 316 | if (false == sp_is_regexp_matching(config_node->r_function, |
| @@ -378,9 +371,12 @@ static void should_disable(zend_execute_data* execute_data, | |||
| 378 | } | 371 | } |
| 379 | 372 | ||
| 380 | if (config_node->r_value || config_node->value) { | 373 | if (config_node->r_value || config_node->value) { |
| 381 | if (check_is_builtin_name(config_node) && !config_node->var && | 374 | if (check_is_builtin_name(config_node) && |
| 382 | !config_node->param && !config_node->r_param && !config_node->key && | 375 | !config_node->var && |
| 383 | !config_node->r_key) { | 376 | !config_node->key && |
| 377 | !config_node->r_key && | ||
| 378 | !config_node->param && | ||
| 379 | !config_node->r_param) { | ||
| 384 | if (false == is_param_matching(execute_data, config_node, builtin_param, | 380 | if (false == is_param_matching(execute_data, config_node, builtin_param, |
| 385 | &arg_name, builtin_param_name, | 381 | &arg_name, builtin_param_name, |
| 386 | &arg_value_str)) { | 382 | &arg_value_str)) { |
| @@ -448,7 +444,7 @@ static void should_drop_on_ret(const zval* return_value, | |||
| 448 | } else if (config_node->function) { | 444 | } else if (config_node->function) { |
| 449 | if (0 != | 445 | if (0 != |
| 450 | strcmp(ZSTR_VAL(config_node->function), complete_function_path)) { | 446 | strcmp(ZSTR_VAL(config_node->function), complete_function_path)) { |
| 451 | goto next; | 447 | goto next; // LCOV_EXCL_LINE |
| 452 | } | 448 | } |
| 453 | } else if (config_node->r_function) { | 449 | } else if (config_node->r_function) { |
| 454 | if (false == sp_is_regexp_matching(config_node->r_function, | 450 | if (false == sp_is_regexp_matching(config_node->r_function, |
