Skip to content

Fix GH-24802: guard request_parse_body() against reentrancy - #24987

Open
lazerg wants to merge 1 commit into
php:PHP-8.4from
lazerg:fix/gh-24802
Open

lazerg wants to merge 1 commit into
php:PHP-8.4from
lazerg:fix/gh-24802

Conversation

@lazerg

@lazerg lazerg commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

request_parse_body() has no reentrancy guard. If a user error handler that fires during multipart parsing calls it again, the nested parse re-inits and destroys the process-global PG(rfc1867_protected_variables). The outer parse then uses and frees that same table a second time, so the worker crashes on a bad zend_string_release().

The function already keeps its state in SG(request_parse_body_context), so I added an in_progress flag there. A reentrant call now throws RequestParseBodyException instead of parsing again, and the flag is cleared on exit and at the per-request reset points.

Fixes #24802

@lazerg
lazerg requested a review from bukka as a code owner October 28, 2026 01:52
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