diff options
| author | jvoisin | 2021-05-09 23:12:07 +0200 |
|---|---|---|
| committer | jvoisin | 2021-05-09 23:12:07 +0200 |
| commit | 8353de00398b13f6c94eeab6e2401d2e590543c6 (patch) | |
| tree | ce7b388456098a5df6af5eb16583e8a92e058474 /src | |
| parent | d934db81cdcd64086c8867bb422bfa7e0d18bb38 (diff) | |
Add some guard to prevent hooking recursion
This shouldn't be necessary, but better safe than sorry.
Diffstat (limited to 'src')
| -rw-r--r-- | src/sp_execute.c | 24 | ||||
| -rw-r--r-- | src/sp_sloppy.c | 5 |
2 files changed, 18 insertions, 11 deletions
diff --git a/src/sp_execute.c b/src/sp_execute.c index de83a2a..7d078b0 100644 --- a/src/sp_execute.c +++ b/src/sp_execute.c | |||
| @@ -274,17 +274,23 @@ int hook_execute(void) { | |||
| 274 | TSRMLS_FETCH(); | 274 | TSRMLS_FETCH(); |
| 275 | 275 | ||
| 276 | if (NULL == orig_execute_ex && NULL == orig_zend_stream_open) { | 276 | if (NULL == orig_execute_ex && NULL == orig_zend_stream_open) { |
| 277 | /* zend_execute_ex is used for "user" function calls */ | 277 | if (zend_execute_ex != sp_execute_ex) { |
| 278 | orig_execute_ex = zend_execute_ex; | 278 | /* zend_execute_ex is used for "user" function calls */ |
| 279 | zend_execute_ex = sp_execute_ex; | 279 | orig_execute_ex = zend_execute_ex; |
| 280 | zend_execute_ex = sp_execute_ex; | ||
| 281 | } | ||
| 280 | 282 | ||
| 281 | /* zend_execute_internal is used for "builtin" functions calls */ | 283 | if (zend_execute_internal != sp_zend_execute_internal) { |
| 282 | orig_zend_execute_internal = zend_execute_internal; | 284 | /* zend_execute_internal is used for "builtin" functions calls */ |
| 283 | zend_execute_internal = sp_zend_execute_internal; | 285 | orig_zend_execute_internal = zend_execute_internal; |
| 286 | zend_execute_internal = sp_zend_execute_internal; | ||
| 287 | } | ||
| 284 | 288 | ||
| 285 | /* zend_stream_open_function is used for include-related stuff */ | 289 | if (zend_stream_open_function != sp_stream_open) { |
| 286 | orig_zend_stream_open = zend_stream_open_function; | 290 | /* zend_stream_open_function is used for include-related stuff */ |
| 287 | zend_stream_open_function = sp_stream_open; | 291 | orig_zend_stream_open = zend_stream_open_function; |
| 292 | zend_stream_open_function = sp_stream_open; | ||
| 293 | } | ||
| 288 | } | 294 | } |
| 289 | 295 | ||
| 290 | return SUCCESS; | 296 | return SUCCESS; |
diff --git a/src/sp_sloppy.c b/src/sp_sloppy.c index f9ed718..ff2d644 100644 --- a/src/sp_sloppy.c +++ b/src/sp_sloppy.c | |||
| @@ -99,12 +99,13 @@ PHP_FUNCTION(sp_array_keys) { | |||
| 99 | void hook_sloppy() { | 99 | void hook_sloppy() { |
| 100 | TSRMLS_FETCH(); | 100 | TSRMLS_FETCH(); |
| 101 | 101 | ||
| 102 | if (NULL == orig_zend_compile_file) { | 102 | if (NULL == orig_zend_compile_file && zend_compile_file != sp_compile_file) { |
| 103 | orig_zend_compile_file = zend_compile_file; | 103 | orig_zend_compile_file = zend_compile_file; |
| 104 | zend_compile_file = sp_compile_file; | 104 | zend_compile_file = sp_compile_file; |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | if (NULL == orig_zend_compile_string) { | 107 | if (NULL == orig_zend_compile_string && |
| 108 | zend_compile_string != sp_compile_string) { | ||
| 108 | orig_zend_compile_string = zend_compile_string; | 109 | orig_zend_compile_string = zend_compile_string; |
| 109 | zend_compile_string = sp_compile_string; | 110 | zend_compile_string = sp_compile_string; |
| 110 | } | 111 | } |
