diff options
4 files changed, 35 insertions, 6 deletions
diff --git a/doc/source/config.rst b/doc/source/config.rst index dd30723..258b1ab 100644 --- a/doc/source/config.rst +++ b/doc/source/config.rst | |||
| @@ -328,7 +328,8 @@ The ``function`` filter is able to do various dereferencing: | |||
| 328 | - ``function("AwesomeNamespace\\my_function")`` will match the function ``my_function`` in the namespace ``AwesomeNamespace`` | 328 | - ``function("AwesomeNamespace\\my_function")`` will match the function ``my_function`` in the namespace ``AwesomeNamespace`` |
| 329 | 329 | ||
| 330 | It's also able to have calltrace constrains: ``function(func1>func2)`` will | 330 | It's also able to have calltrace constrains: ``function(func1>func2)`` will |
| 331 | match only if ``func2`` is called **inside** of ``func1``. | 331 | match only if ``func2`` is called **inside** of ``func1``. Do note that their |
| 332 | might be other functions called between them. | ||
| 332 | 333 | ||
| 333 | The ``param`` filter is able to do some dereferencing as well: | 334 | The ``param`` filter is able to do some dereferencing as well: |
| 334 | 335 | ||
diff --git a/src/sp_disabled_functions.c b/src/sp_disabled_functions.c index 7be1c34..7e6ca6a 100644 --- a/src/sp_disabled_functions.c +++ b/src/sp_disabled_functions.c | |||
| @@ -40,7 +40,7 @@ static bool is_functions_list_matching(zend_execute_data* execute_data, | |||
| 40 | sp_list_node* functions_list) { | 40 | sp_list_node* functions_list) { |
| 41 | zend_execute_data *orig_execute_data, *current; | 41 | zend_execute_data *orig_execute_data, *current; |
| 42 | orig_execute_data = current = execute_data; | 42 | orig_execute_data = current = execute_data; |
| 43 | sp_list_node* it = functions_list; | 43 | sp_list_node const * it = functions_list; |
| 44 | 44 | ||
| 45 | while (current) { | 45 | while (current) { |
| 46 | if (it == NULL) { // every function in the list matched, we've got a match! | 46 | if (it == NULL) { // every function in the list matched, we've got a match! |
| @@ -50,7 +50,7 @@ static bool is_functions_list_matching(zend_execute_data* execute_data, | |||
| 50 | 50 | ||
| 51 | EG(current_execute_data) = current; | 51 | EG(current_execute_data) = current; |
| 52 | 52 | ||
| 53 | char* complete_path_function = get_complete_function_path(current); | 53 | char* const complete_path_function = get_complete_function_path(current); |
| 54 | if (!complete_path_function) { | 54 | if (!complete_path_function) { |
| 55 | break; | 55 | break; |
| 56 | } | 56 | } |
| @@ -59,10 +59,8 @@ static bool is_functions_list_matching(zend_execute_data* execute_data, | |||
| 59 | 59 | ||
| 60 | if (0 == match) { | 60 | if (0 == match) { |
| 61 | it = it->next; | 61 | it = it->next; |
| 62 | current = current->prev_execute_data; | ||
| 63 | } else { | ||
| 64 | break; | ||
| 65 | } | 62 | } |
| 63 | current = current->prev_execute_data; | ||
| 66 | } | 64 | } |
| 67 | 65 | ||
| 68 | EG(current_execute_data) = orig_execute_data; | 66 | EG(current_execute_data) = orig_execute_data; |
diff --git a/src/tests/disable_function/config/config_disabled_functions_chain_call_skip.ini b/src/tests/disable_function/config/config_disabled_functions_chain_call_skip.ini new file mode 100644 index 0000000..4d2f68d --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_chain_call_skip.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("a>c").simulation().drop(); | |||
diff --git a/src/tests/disable_function/disabled_functions_chain_call_skip.phpt b/src/tests/disable_function/disabled_functions_chain_call_skip.phpt new file mode 100644 index 0000000..9ff84b9 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_chain_call_skip.phpt | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions by matching the calltrace, with a superfluous function in between | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_chain_call_skip.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | |||
| 10 | function a() { | ||
| 11 | echo "I'm in the `a` function!\n"; | ||
| 12 | b(); | ||
| 13 | } | ||
| 14 | function b() { | ||
| 15 | echo "I'm in the `b` function!\n"; | ||
| 16 | c(); | ||
| 17 | } | ||
| 18 | function c() { | ||
| 19 | echo "I'm in the `c` function!\n"; | ||
| 20 | } | ||
| 21 | |||
| 22 | a(); | ||
| 23 | ?> | ||
| 24 | --EXPECTF-- | ||
| 25 | I'm in the `a` function! | ||
| 26 | I'm in the `b` function! | ||
| 27 | |||
| 28 | Warning: [snuffleupagus][0.0.0.0][disabled_function][simulation] Aborted execution on call of the function 'a>c' in %s/tests/disable_function/disabled_functions_chain_call_skip.php on line 12 | ||
| 29 | I'm in the `c` function! | ||
