diff options
| author | Ben Fuhrmannek | 2021-09-15 20:26:02 +0200 |
|---|---|---|
| committer | Ben Fuhrmannek | 2021-09-15 20:26:02 +0200 |
| commit | 31d6a3cddd18cef447698ba2beaa7b5d9ab9dd94 (patch) | |
| tree | 015c69027703d17061d429375de84a86cc51186a /src/sp_execute.c | |
| parent | 8e42064026906f0f25caca237e4624b5b3c5087e (diff) | |
implemented execution depth limit
Diffstat (limited to '')
| -rw-r--r-- | src/sp_execute.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/sp_execute.c b/src/sp_execute.c index 8795e5f..41257ad 100644 --- a/src/sp_execute.c +++ b/src/sp_execute.c | |||
| @@ -112,6 +112,15 @@ zend_string *get_eval_filename(const char *const filename) { | |||
| 112 | return clean_filename; | 112 | return clean_filename; |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | static inline void sp_orig_execute(zend_execute_data *execute_data) { | ||
| 116 | SNUFFLEUPAGUS_G(execution_depth)++; | ||
| 117 | if (SNUFFLEUPAGUS_G(execution_depth) > SNUFFLEUPAGUS_G(config).max_execution_depth && SNUFFLEUPAGUS_G(config).max_execution_depth > 0) { | ||
| 118 | sp_log_drop("execute", "Maximum recursion limit reached. Script terminated."); | ||
| 119 | } | ||
| 120 | orig_execute_ex(execute_data); | ||
| 121 | SNUFFLEUPAGUS_G(execution_depth)--; | ||
| 122 | } | ||
| 123 | |||
| 115 | static void sp_execute_ex(zend_execute_data *execute_data) { | 124 | static void sp_execute_ex(zend_execute_data *execute_data) { |
| 116 | is_in_eval_and_whitelisted(execute_data); | 125 | is_in_eval_and_whitelisted(execute_data); |
| 117 | const HashTable *config_disabled_functions = | 126 | const HashTable *config_disabled_functions = |
| @@ -131,7 +140,7 @@ static void sp_execute_ex(zend_execute_data *execute_data) { | |||
| 131 | zend_string_release(filename); | 140 | zend_string_release(filename); |
| 132 | 141 | ||
| 133 | SNUFFLEUPAGUS_G(in_eval)++; | 142 | SNUFFLEUPAGUS_G(in_eval)++; |
| 134 | orig_execute_ex(execute_data); | 143 | sp_orig_execute(execute_data); |
| 135 | SNUFFLEUPAGUS_G(in_eval)--; | 144 | SNUFFLEUPAGUS_G(in_eval)--; |
| 136 | return; | 145 | return; |
| 137 | } | 146 | } |
| @@ -150,7 +159,7 @@ static void sp_execute_ex(zend_execute_data *execute_data) { | |||
| 150 | .config_disabled_functions_reg->disabled_functions; | 159 | .config_disabled_functions_reg->disabled_functions; |
| 151 | 160 | ||
| 152 | if (!function_name) { | 161 | if (!function_name) { |
| 153 | orig_execute_ex(execute_data); | 162 | sp_orig_execute(execute_data); |
| 154 | return; | 163 | return; |
| 155 | } | 164 | } |
| 156 | 165 | ||
| @@ -184,7 +193,7 @@ static void sp_execute_ex(zend_execute_data *execute_data) { | |||
| 184 | EX(return_value) = &ret_val; | 193 | EX(return_value) = &ret_val; |
| 185 | } | 194 | } |
| 186 | 195 | ||
| 187 | orig_execute_ex(execute_data); | 196 | sp_orig_execute(execute_data); |
| 188 | 197 | ||
| 189 | should_drop_on_ret_ht( | 198 | should_drop_on_ret_ht( |
| 190 | EX(return_value), function_name, | 199 | EX(return_value), function_name, |
| @@ -197,7 +206,7 @@ static void sp_execute_ex(zend_execute_data *execute_data) { | |||
| 197 | EX(return_value) = NULL; | 206 | EX(return_value) = NULL; |
| 198 | } | 207 | } |
| 199 | } else { | 208 | } else { |
| 200 | orig_execute_ex(execute_data); | 209 | sp_orig_execute(execute_data); |
| 201 | } | 210 | } |
| 202 | } | 211 | } |
| 203 | 212 | ||
