diff options
author | Keyur <kgovande@etsy.com> | 2016-06-29 19:58:29 +0000 |
---|---|---|
committer | Julien Pauli <jpauli@php.net> | 2016-07-12 17:17:04 +0200 |
commit | b31f8be143655260c9a83a0cd64b5b555244c525 (patch) | |
tree | 41927d198ab513b16870c4abdd439f4d899db17c /Zend/zend_execute_API.c | |
parent | ff5228752fb408a94f74d6aa128dcae933367146 (diff) | |
download | php-git-b31f8be143655260c9a83a0cd64b5b555244c525.tar.gz |
Safer signal handler (no malloc() call)
Diffstat (limited to 'Zend/zend_execute_API.c')
-rw-r--r-- | Zend/zend_execute_API.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index f79aba28c9..c039bb85d2 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -1188,7 +1188,8 @@ static void zend_timeout_handler(int dummy) /* {{{ */ /* Die on hard timeout */ const char *error_filename = NULL; uint error_lineno = 0; - char *log_buffer = NULL; + char log_buffer[2048]; + int output_len = 0; if (zend_is_compiling()) { error_filename = ZSTR_VAL(zend_get_compiled_filename()); @@ -1206,8 +1207,10 @@ static void zend_timeout_handler(int dummy) /* {{{ */ error_filename = "Unknown"; } - zend_spprintf(&log_buffer, 0, "\nFatal error: Maximum execution time of " ZEND_LONG_FMT "+" ZEND_LONG_FMT " seconds exceeded (terminated) in %s on line %d\n", EG(timeout_seconds), EG(hard_timeout), error_filename, error_lineno); - write(2, log_buffer, strlen(log_buffer)); + output_len = snprintf(log_buffer, sizeof(log_buffer), "\nFatal error: Maximum execution time of " ZEND_LONG_FMT "+" ZEND_LONG_FMT " seconds exceeded (terminated) in %s on line %d\n", EG(timeout_seconds), EG(hard_timeout), error_filename, error_lineno); + if (output_len > 0) { + write(2, log_buffer, MIN(output_len, sizeof(log_buffer))); + } _exit(1); } #endif |