FPM: Emit error for invalid port setting

This commit is contained in:
David Carlier 2022-03-19 15:16:07 +00:00 committed by Jakub Zelenka
parent 8620788c2a
commit 2874e5fa05
3 changed files with 40 additions and 1 deletions

3
NEWS
View File

@ -10,6 +10,9 @@ PHP NEWS
. Fixed bug GH-7771 (Fix filename/lineno of constant expressions). (ilutov)
. Fixed bug GH-7792 (Improve class type in error messages). (ilutov)
- FPM:
. Emit error for invalid port setting. (David Carlier)
- Intl:
. Update all grandfathered language tags with preferred values
. Fixed GH-7939 (Cannot unserialize IntlTimeZone objects). (cmb)

View File

@ -334,7 +334,7 @@ static int fpm_socket_af_inet_listening_socket(struct fpm_worker_pool_s *wp) /*
port_str = dup_address;
}
if (port == 0) {
if (port < 1 || port > 65535) {
zlog(ZLOG_ERROR, "invalid port value '%s'", port_str);
free(dup_address);
return -1;

View File

@ -0,0 +1,36 @@
--TEST--
FPM: test invalid port value
--SKIPIF--
<?php include "skipif.inc"; ?>
--FILE--
<?php
require_once "tester.inc";
$cfg = <<<EOT
[global]
error_log = {{FILE:LOG}}
[unconfined]
listen = 127.0.0.1:69002
pm = dynamic
pm.max_children = 1
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 1
EOT;
$tester = new FPM\Tester($cfg);
$tester->start();
$tester->expectLogError("invalid port value '69002'");
$tester->terminate();
$tester->close();
?>
Done
--EXPECT--
Done
--CLEAN--
<?php
require_once "tester.inc";
FPM\Tester::clean();
?>