diff options
| author | jvoisin | 2018-08-09 15:37:25 +0200 |
|---|---|---|
| committer | jvoisin | 2018-08-09 15:39:28 +0200 |
| commit | 00160b4430a7a02656fc07a7752d1c2d83e80871 (patch) | |
| tree | 694bd843ef5b8db8d158ed9446cecc3dce722259 /src/sp_execute.c | |
| parent | 14010de608d59cfaf4a25587582fb512403b9c49 (diff) | |
Fix a crash/hang when using fpm's pools
We might have ended up in infinite loops when using
php-fpm, if several different process hooked
some functions twice.
Thanks to @sriccio for reporting the issue
Diffstat (limited to 'src/sp_execute.c')
| -rw-r--r-- | src/sp_execute.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/sp_execute.c b/src/sp_execute.c index 1c1672a..134aab2 100644 --- a/src/sp_execute.c +++ b/src/sp_execute.c | |||
| @@ -9,7 +9,7 @@ static void (*orig_execute_ex)(zend_execute_data *execute_data); | |||
| 9 | static void (*orig_zend_execute_internal)(zend_execute_data *execute_data, | 9 | static void (*orig_zend_execute_internal)(zend_execute_data *execute_data, |
| 10 | zval *return_value); | 10 | zval *return_value); |
| 11 | static int (*orig_zend_stream_open)(const char *filename, | 11 | static int (*orig_zend_stream_open)(const char *filename, |
| 12 | zend_file_handle *handle); | 12 | zend_file_handle *handle) = NULL; |
| 13 | 13 | ||
| 14 | // FIXME handle symlink | 14 | // FIXME handle symlink |
| 15 | ZEND_COLD static inline void terminate_if_writable(const char *filename) { | 15 | ZEND_COLD static inline void terminate_if_writable(const char *filename) { |
| @@ -271,17 +271,23 @@ end: | |||
| 271 | int hook_execute(void) { | 271 | int hook_execute(void) { |
| 272 | TSRMLS_FETCH(); | 272 | TSRMLS_FETCH(); |
| 273 | 273 | ||
| 274 | /* zend_execute_ex is used for "user" function calls */ | 274 | if (NULL == orig_zend_stream_open) { |
| 275 | orig_execute_ex = zend_execute_ex; | 275 | /* zend_execute_ex is used for "user" function calls */ |
| 276 | zend_execute_ex = sp_execute_ex; | 276 | orig_execute_ex = zend_execute_ex; |
| 277 | zend_execute_ex = sp_execute_ex; | ||
| 278 | } | ||
| 277 | 279 | ||
| 278 | /* zend_execute_internal is used for "builtin" functions calls */ | 280 | if (NULL == orig_zend_execute_internal) { |
| 279 | orig_zend_execute_internal = zend_execute_internal; | 281 | /* zend_execute_internal is used for "builtin" functions calls */ |
| 280 | zend_execute_internal = sp_zend_execute_internal; | 282 | orig_zend_execute_internal = zend_execute_internal; |
| 283 | zend_execute_internal = sp_zend_execute_internal; | ||
| 284 | } | ||
| 281 | 285 | ||
| 282 | /* zend_stream_open_function is used for include-related stuff */ | 286 | if (NULL == orig_zend_stream_open) { |
| 283 | orig_zend_stream_open = zend_stream_open_function; | 287 | /* zend_stream_open_function is used for include-related stuff */ |
| 284 | zend_stream_open_function = sp_stream_open; | 288 | orig_zend_stream_open = zend_stream_open_function; |
| 289 | zend_stream_open_function = sp_stream_open; | ||
| 290 | } | ||
| 285 | 291 | ||
| 286 | return SUCCESS; | 292 | return SUCCESS; |
| 287 | } | 293 | } |
