com php-src: Safer signal handler (no malloc() call): Zend/zend_execute_API.c
| From: | JulienPauli | Date: | Tue, 12 Jul 2016 15:17:04 +0000 |
| Subject: | com php-src: Safer signal handler (no malloc() call): Zend/zend_execute_API.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-92979@lists.php.net to get a copy of this message | ||
Commit: b31f8be143655260c9a83a0cd64b5b555244c525
Author: Keyur <kgovande@etsy.com> Wed, 29 Jun 2016 19:58:29 +0000
Committer: Julien Pauli <jpauli@php.net> Tue, 12 Jul 2016 17:17:04 +0200
Parents: ff5228752fb408a94f74d6aa128dcae933367146
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b31f8be143655260c9a83a0cd64b5b555244c525
Log:
Safer signal handler (no malloc() call)
Changed paths:
M Zend/zend_execute_API.c
Diff:
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index f79aba2..c039bb8 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