diff options
-rw-r--r-- | php-bug77653.patch | 159 | ||||
-rw-r--r-- | php.spec | 8 |
2 files changed, 166 insertions, 1 deletions
diff --git a/php-bug77653.patch b/php-bug77653.patch new file mode 100644 index 0000000..98fc4d1 --- /dev/null +++ b/php-bug77653.patch @@ -0,0 +1,159 @@ +From 06dd1d78a7ec1678b53ef657033c2021f4dc902f Mon Sep 17 00:00:00 2001 +From: Jakub Zelenka <bukka@php.net> +Date: Sun, 31 Mar 2019 16:56:17 +0100 +Subject: [PATCH 1/2] Fix logging in shutdown function + +--- + sapi/fpm/fpm/fpm_stdio.c | 20 +++++++-- + sapi/fpm/tests/log-bm-in-shutdown-fn.phpt | 49 +++++++++++++++++++++++ + 2 files changed, 65 insertions(+), 4 deletions(-) + create mode 100644 sapi/fpm/tests/log-bm-in-shutdown-fn.phpt + +diff --git a/sapi/fpm/fpm/fpm_stdio.c b/sapi/fpm/fpm/fpm_stdio.c +index 03d15cbf0d7c..75c4d8e9c262 100644 +--- a/sapi/fpm/fpm/fpm_stdio.c ++++ b/sapi/fpm/fpm/fpm_stdio.c +@@ -106,9 +106,11 @@ int fpm_stdio_init_child(struct fpm_worker_pool_s *wp) /* {{{ */ + } + /* }}} */ + ++#define FPM_STDIO_CMD_FLUSH "\0fscf" ++ + int fpm_stdio_flush_child() /* {{{ */ + { +- return write(STDERR_FILENO, "\0", 1); ++ return write(STDERR_FILENO, FPM_STDIO_CMD_FLUSH, sizeof(FPM_STDIO_CMD_FLUSH)); + } + /* }}} */ + +@@ -162,10 +164,20 @@ static void fpm_stdio_child_said(struct fpm_event_s *ev, short which, void *arg) + } + } else { + in_buf += res; +- /* if buffer ends with \0, then the stream will be finished */ +- if (!buf[in_buf - 1]) { ++ /* check if buffer should be flushed */ ++ if (!buf[in_buf - 1] && in_buf >= sizeof(FPM_STDIO_CMD_FLUSH) && ++ !memcmp(buf + in_buf - sizeof(FPM_STDIO_CMD_FLUSH), ++ FPM_STDIO_CMD_FLUSH, sizeof(FPM_STDIO_CMD_FLUSH))) { ++ /* if buffer ends with flush cmd, then the stream will be finished */ ++ finish_log_stream = 1; ++ in_buf -= sizeof(FPM_STDIO_CMD_FLUSH); ++ } else if (!buf[0] && in_buf > sizeof(FPM_STDIO_CMD_FLUSH) && ++ !memcmp(buf, FPM_STDIO_CMD_FLUSH, sizeof(FPM_STDIO_CMD_FLUSH))) { ++ /* if buffer starts with flush cmd, then the stream will be finished */ + finish_log_stream = 1; +- in_buf--; ++ in_buf -= sizeof(FPM_STDIO_CMD_FLUSH); ++ /* move data behind the flush cmd */ ++ memmove(buf, buf + sizeof(FPM_STDIO_CMD_FLUSH), in_buf); + } + } + } +diff --git a/sapi/fpm/tests/log-bm-in-shutdown-fn.phpt b/sapi/fpm/tests/log-bm-in-shutdown-fn.phpt +new file mode 100644 +index 000000000000..f968bf9f08bc +--- /dev/null ++++ b/sapi/fpm/tests/log-bm-in-shutdown-fn.phpt +@@ -0,0 +1,49 @@ ++--TEST-- ++FPM: Log message in shutdown function ++--SKIPIF-- ++<?php include "skipif.inc"; ?> ++--FILE-- ++<?php ++ ++require_once "tester.inc"; ++ ++$cfg = <<<EOT ++[global] ++error_log = {{FILE:LOG}} ++log_limit = 1024 ++log_buffering = yes ++[unconfined] ++listen = {{ADDR}} ++pm = dynamic ++pm.max_children = 5 ++pm.start_servers = 1 ++pm.min_spare_servers = 1 ++pm.max_spare_servers = 3 ++catch_workers_output = yes ++EOT; ++ ++$code = <<<EOT ++<?php ++register_shutdown_function(function() { ++ error_log(str_repeat('e', 80)); ++}); ++EOT; ++ ++$tester = new FPM\Tester($cfg, $code); ++$tester->start(); ++$tester->expectLogStartNotices(); ++$tester->request()->expectEmptyBody(); ++$tester->terminate(); ++$tester->expectFastCGIErrorMessage('e', 1050, 80); ++$tester->expectLogMessage('NOTICE: PHP message: ' . str_repeat('e', 80), 1050); ++$tester->close(); ++ ++?> ++Done ++--EXPECT-- ++Done ++--CLEAN-- ++<?php ++require_once "tester.inc"; ++FPM\Tester::clean(); ++?> + +From 72c010309bb0a7bb032677ca599424ceb2ad4883 Mon Sep 17 00:00:00 2001 +From: Jakub Zelenka <bukka@php.net> +Date: Sun, 31 Mar 2019 17:55:29 +0100 +Subject: [PATCH 2/2] Move stdio flush behind request shutdown + +--- + sapi/fpm/fpm/fpm_main.c | 3 +++ + sapi/fpm/fpm/fpm_request.c | 2 -- + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c +index 483fabe9d850..bfd82a1c2e11 100644 +--- a/sapi/fpm/fpm/fpm_main.c ++++ b/sapi/fpm/fpm/fpm_main.c +@@ -90,6 +90,7 @@ int __riscosify_control = __RISCOSIFY_STRICT_UNIX_SPECS; + #include "fpm.h" + #include "fpm_request.h" + #include "fpm_status.h" ++#include "fpm_stdio.h" + #include "fpm_conf.h" + #include "fpm_php.h" + #include "fpm_log.h" +@@ -1977,6 +1978,8 @@ consult the installation file that came with this distribution, or visit \n\ + + php_request_shutdown((void *) 0); + ++ fpm_stdio_flush_child(); ++ + requests++; + if (UNEXPECTED(max_requests && (requests == max_requests))) { + fcgi_request_set_keep(request, 0); +diff --git a/sapi/fpm/fpm/fpm_request.c b/sapi/fpm/fpm/fpm_request.c +index 65f9c4ae441c..2aa503891ed9 100644 +--- a/sapi/fpm/fpm/fpm_request.c ++++ b/sapi/fpm/fpm/fpm_request.c +@@ -16,7 +16,6 @@ + #include "fpm_children.h" + #include "fpm_scoreboard.h" + #include "fpm_status.h" +-#include "fpm_stdio.h" + #include "fpm_request.h" + #include "fpm_log.h" + +@@ -200,7 +199,6 @@ void fpm_request_end(void) /* {{{ */ + #endif + proc->memory = memory; + fpm_scoreboard_proc_release(proc); +- fpm_stdio_flush_child(); + } + /* }}} */ + @@ -136,7 +136,7 @@ Summary: PHP scripting language for creating dynamic web sites Name: %{?scl_prefix}php Version: %{upver}%{?rcver:~%{lower}} -Release: 1%{?dist} +Release: 2%{?dist} # All files licensed under PHP version 3.01, except # Zend is licensed under Zend # TSRM is licensed under BSD @@ -192,6 +192,7 @@ Patch91: php-7.2.0-oci8conf.patch # Upstream fixes (100+) Patch100: php-upstream.patch +Patch101: php-bug77653.patch # Security fixes (200+) @@ -945,6 +946,7 @@ low-level PHP extension for the libsodium cryptographic library. # upstream patches %patch100 -p1 -b .up +%patch101 -p1 -b .bug77653 # security patches @@ -1887,6 +1889,10 @@ fi %changelog +* Wed Apr 3 2019 Remi Collet <remi@remirepo.net> - 7.3.4-4 +- test build for https://bugs.php.net/77653 + patch from https://github.com/php/php-src/pull/4007 + * Tue Apr 2 2019 Remi Collet <remi@remirepo.net> - 7.3.4-1 - Update to 7.3.4 - http://www.php.net/releases/7_3_4.php |