Skip to content

Fix GH-23764: Built-in server leaks fd on HEAD request for static file - #23765

Open
jakubskopal wants to merge 1 commit into
php:PHP-8.4from
jakubskopal:fix-gh-23764
Open

jakubskopal wants to merge 1 commit into
php:PHP-8.4from
jakubskopal:fix-gh-23764

Conversation

@jakubskopal

Copy link
Copy Markdown

Fixes GH-23764.

php_cli_server_begin_send_static() opens the file, but for HEAD requests never stores the descriptor in client->file_fd, so nothing closes it. Close it right away; Content-Length comes from the stat and the body is never sent, so the descriptor is not needed.

Verified with a --disable-all build: after 100 curl -I requests, /proc/<pid>/fd holds 0 references to the served file (previously 100); HEAD and GET responses unchanged.

Bug exists since 8.2 (#8215); targeting PHP-8.4 as the lowest branch still receiving bug fixes.

…file

php_cli_server_begin_send_static() opens the file, but for HEAD requests
never stores the descriptor in client->file_fd, so nothing closes it.
Close it right away; Content-Length comes from the stat and the body is
never sent, so the descriptor is not needed.
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