Browse Source

Merge branch 'PHP-7.1' into PHP-7.2

pull/3320/head
Nikita Popov 8 years ago
parent
commit
44f4d2be01
  1. 4
      NEWS
  2. 1
      sapi/fpm/fpm/fpm_children.c
  3. 6
      sapi/fpm/fpm/fpm_stdio.c
  4. 46
      sapi/fpm/tests/bug73342-nonblocking-stdio.phpt

4
NEWS

@ -8,6 +8,10 @@ PHP NEWS
- EXIF:
. Fixed bug #76409 (heap use after free in _php_stream_free). (cmb)
- FPM:
. Fixed bug #73342 (Vulnerability in php-fpm by changing stdin to
non-blocking). (Nikita)
- Opcache:
. Fixed bug #76477 (Opcache causes empty return value).
(Nikita, Laruence)

1
sapi/fpm/fpm/fpm_children.c

@ -146,6 +146,7 @@ static struct fpm_child_s *fpm_child_find(pid_t pid) /* {{{ */
static void fpm_child_init(struct fpm_worker_pool_s *wp) /* {{{ */
{
fpm_globals.max_requests = wp->config->pm_max_requests;
fpm_globals.listening_socket = dup(wp->listening_socket);
if (0 > fpm_stdio_init_child(wp) ||
0 > fpm_log_init_child(wp) ||

6
sapi/fpm/fpm/fpm_stdio.c

@ -103,12 +103,6 @@ int fpm_stdio_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
fpm_globals.error_log_fd = -1;
zlog_set_fd(-1);
if (wp->listening_socket != STDIN_FILENO) {
if (0 > dup2(wp->listening_socket, STDIN_FILENO)) {
zlog(ZLOG_SYSERROR, "failed to init child stdio: dup2()");
return -1;
}
}
return 0;
}
/* }}} */

46
sapi/fpm/tests/bug73342-nonblocking-stdio.phpt

@ -0,0 +1,46 @@
--TEST--
FPM: bug73342 - Non-blocking stdin
--SKIPIF--
<?php include "skipif.inc"; ?>
--FILE--
<?php
require_once "tester.inc";
$cfg = <<<EOT
[global]
error_log = {{FILE:LOG}}
[unconfined]
listen = {{ADDR}}
pm = dynamic
pm.max_children = 5
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 3
EOT;
$code = <<<EOT
<?php
echo "Before\n";
stream_set_blocking(fopen('php://stdin', 'r'), false);
echo "After\n";
EOT;
$tester = new FPM\Tester($cfg, $code);
$tester->start();
$tester->expectLogStartNotices();
$tester->request()->expectBody("Before\nAfter");
$tester->request()->expectBody("Before\nAfter");
$tester->terminate();
$tester->expectLogTerminatingNotices();
$tester->close();
?>
Done
--EXPECT--
Done
--CLEAN--
<?php
require_once "tester.inc";
FPM\Tester::clean();
?>
Loading…
Cancel
Save