diff options
| author | xXx-caillou-xXx | 2018-08-30 14:43:58 +0200 |
|---|---|---|
| committer | jvoisin | 2018-08-30 12:43:58 +0000 |
| commit | f61a4772bfc33e08e7b06250e2f0f640bcae875f (patch) | |
| tree | 2c26573cdd6ffa9eed1a46291660d82611154eb0 /src/sp_execute.c | |
| parent | dcc64e0f1530fbe5d528873977199ceeb715305d (diff) | |
Match on ret improvements
This commit does two things:
- Implement matching on calltraces for ret
- Implement matching on ret of user functions if the return value is not used.
Diffstat (limited to 'src/sp_execute.c')
| -rw-r--r-- | src/sp_execute.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/sp_execute.c b/src/sp_execute.c index 844647e..5447ea1 100644 --- a/src/sp_execute.c +++ b/src/sp_execute.c | |||
| @@ -151,6 +151,7 @@ static void sp_execute_ex(zend_execute_data *execute_data) { | |||
| 151 | 151 | ||
| 152 | if (SNUFFLEUPAGUS_G(config).hook_execute) { | 152 | if (SNUFFLEUPAGUS_G(config).hook_execute) { |
| 153 | char *function_name = get_complete_function_path(execute_data); | 153 | char *function_name = get_complete_function_path(execute_data); |
| 154 | zval ret_val; | ||
| 154 | 155 | ||
| 155 | if (!function_name) { | 156 | if (!function_name) { |
| 156 | orig_execute_ex(execute_data); | 157 | orig_execute_ex(execute_data); |
| @@ -185,23 +186,34 @@ static void sp_execute_ex(zend_execute_data *execute_data) { | |||
| 185 | } | 186 | } |
| 186 | } | 187 | } |
| 187 | 188 | ||
| 189 | // When a function's return value isn't used, php doesn't store it in the execute_data, | ||
| 190 | // so we need to use a local variable to be able to match on it later. | ||
| 191 | if (EX(return_value) == NULL) { | ||
| 192 | memset(&ret_val, 0, sizeof(ret_val)); | ||
| 193 | EX(return_value) = &ret_val; | ||
| 194 | } | ||
| 195 | |||
| 188 | orig_execute_ex(execute_data); | 196 | orig_execute_ex(execute_data); |
| 189 | 197 | ||
| 190 | if (EX(return_value) != NULL) { | 198 | if (UNEXPECTED( |
| 191 | if (UNEXPECTED( | 199 | true == |
| 192 | true == | 200 | should_drop_on_ret_ht( |
| 193 | should_drop_on_ret_ht( | 201 | EX(return_value), function_name, |
| 194 | EX(return_value), function_name, | 202 | SNUFFLEUPAGUS_G(config) |
| 195 | SNUFFLEUPAGUS_G(config) | 203 | .config_disabled_functions_reg_ret->disabled_functions, |
| 196 | .config_disabled_functions_reg_ret->disabled_functions, | 204 | SNUFFLEUPAGUS_G(config).config_disabled_functions_ret, |
| 197 | SNUFFLEUPAGUS_G(config).config_disabled_functions_ret))) { | 205 | execute_data))) { |
| 198 | sp_terminate(); | 206 | sp_terminate(); |
| 199 | } | ||
| 200 | } | 207 | } |
| 201 | efree(function_name); | 208 | efree(function_name); |
| 209 | |||
| 210 | if (EX(return_value) == &ret_val) { | ||
| 211 | EX(return_value) = NULL; | ||
| 212 | } | ||
| 202 | } else { | 213 | } else { |
| 203 | orig_execute_ex(execute_data); | 214 | orig_execute_ex(execute_data); |
| 204 | } | 215 | } |
| 216 | |||
| 205 | } | 217 | } |
| 206 | 218 | ||
| 207 | static void sp_zend_execute_internal(INTERNAL_FUNCTION_PARAMETERS) { | 219 | static void sp_zend_execute_internal(INTERNAL_FUNCTION_PARAMETERS) { |
