From 2874e5fa052d54affd31ed5eaf3e0d53c9116c93 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 19 Mar 2022 15:16:07 +0000 Subject: [PATCH] FPM: Emit error for invalid port setting --- NEWS | 3 +++ sapi/fpm/fpm/fpm_sockets.c | 2 +- sapi/fpm/tests/log-invalid-port.phpt | 36 ++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 sapi/fpm/tests/log-invalid-port.phpt diff --git a/NEWS b/NEWS index 75e3600f548..c06858ea657 100644 --- a/NEWS +++ b/NEWS @@ -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) diff --git a/sapi/fpm/fpm/fpm_sockets.c b/sapi/fpm/fpm/fpm_sockets.c index 9514979ac1c..003c62b7d05 100644 --- a/sapi/fpm/fpm/fpm_sockets.c +++ b/sapi/fpm/fpm/fpm_sockets.c @@ -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; diff --git a/sapi/fpm/tests/log-invalid-port.phpt b/sapi/fpm/tests/log-invalid-port.phpt new file mode 100644 index 00000000000..361700378eb --- /dev/null +++ b/sapi/fpm/tests/log-invalid-port.phpt @@ -0,0 +1,36 @@ +--TEST-- +FPM: test invalid port value +--SKIPIF-- + +--FILE-- +start(); +$tester->expectLogError("invalid port value '69002'"); +$tester->terminate(); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- +