Skip to content

Commit 2874e5f

Browse files
devnexenbukka
authored andcommitted
FPM: Emit error for invalid port setting
1 parent 8620788 commit 2874e5f

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ PHP NEWS
1010
. Fixed bug GH-7771 (Fix filename/lineno of constant expressions). (ilutov)
1111
. Fixed bug GH-7792 (Improve class type in error messages). (ilutov)
1212

13+
- FPM:
14+
. Emit error for invalid port setting. (David Carlier)
15+
1316
- Intl:
1417
. Update all grandfathered language tags with preferred values
1518
. Fixed GH-7939 (Cannot unserialize IntlTimeZone objects). (cmb)

sapi/fpm/fpm/fpm_sockets.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ static int fpm_socket_af_inet_listening_socket(struct fpm_worker_pool_s *wp) /*
334334
port_str = dup_address;
335335
}
336336

337-
if (port == 0) {
337+
if (port < 1 || port > 65535) {
338338
zlog(ZLOG_ERROR, "invalid port value '%s'", port_str);
339339
free(dup_address);
340340
return -1;

sapi/fpm/tests/log-invalid-port.phpt

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
--TEST--
2+
FPM: test invalid port value
3+
--SKIPIF--
4+
<?php include "skipif.inc"; ?>
5+
--FILE--
6+
<?php
7+
8+
require_once "tester.inc";
9+
10+
$cfg = <<<EOT
11+
[global]
12+
error_log = {{FILE:LOG}}
13+
[unconfined]
14+
listen = 127.0.0.1:69002
15+
pm = dynamic
16+
pm.max_children = 1
17+
pm.start_servers = 1
18+
pm.min_spare_servers = 1
19+
pm.max_spare_servers = 1
20+
EOT;
21+
22+
$tester = new FPM\Tester($cfg);
23+
$tester->start();
24+
$tester->expectLogError("invalid port value '69002'");
25+
$tester->terminate();
26+
$tester->close();
27+
28+
?>
29+
Done
30+
--EXPECT--
31+
Done
32+
--CLEAN--
33+
<?php
34+
require_once "tester.inc";
35+
FPM\Tester::clean();
36+
?>

0 commit comments

Comments
 (0)