Skip to content

Fix php-cgi -b accepting ports above 65535 - #25235

Open
eyupcanakman wants to merge 1 commit into
php:PHP-8.4from
eyupcanakman:fastcgi-port-range
Open

eyupcanakman wants to merge 1 commit into
php:PHP-8.4from
eyupcanakman:fastcgi-port-range

Conversation

@eyupcanakman

Copy link
Copy Markdown
Contributor

php-cgi -b reads the port in fcgi_listen() with atoi() into a short, so a port outside 0-65535 wraps to another one. -b 70000 listens on port 4464, and -b 65536 creates a Unix socket named 65536.

Such ports now fail with the existing error. GH-24616 fixed the same thing for socket streams.

fcgi_listen() read the port with atoi() into a short and did not check
its range, so a port above 65535 or below 0 wrapped to another port.
php-cgi -b 70000 listened on port 4464. Reject such ports, as phpGH-24616
did for socket transports.

The -b error exits in main() returned without shutting the module down,
which leaked. Jump to parent_out instead, like the error paths further
down.
@eyupcanakman

Copy link
Copy Markdown
Contributor Author

The ASAN jobs failed because php-cgi returned from main() without shutting the module down when -b fails, so the leak showed up in the test output. A busy port leaks the same way on PHP-8.4. Both -b error exits now go through parent_out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant