Skip to content

Reset skip_upload per part in rfc1867_post_handler() - #25770

Open
hohphu8 wants to merge 1 commit into
php:PHP-8.4from
hohphu8:fix-rfc1867-sticky-skip-upload
Open

hohphu8 wants to merge 1 commit into
php:PHP-8.4from
hohphu8:fix-rfc1867-sticky-skip-upload

Conversation

@hohphu8

@hohphu8 hohphu8 commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

In rfc1867_post_handler() (main/rfc1867.c), skip_upload is declared outside the multipart while loop and never reset. Once a file part triggers it, for example a field name with malformed brackets such as name="bad[", every later file part in the same request is skipped as well, while later non-file fields are still parsed into $_POST.

This moves skip_upload into the loop body so it is evaluated per part. The !PG(file_uploads) and upload_cnt <= 0 branches set it again on each iteration, so their behavior is unchanged.

Adds tests/basic/rfc1867_malformed_bracket_skip_upload.phpt: a malformed file part followed by a valid one and a plain field. It fails before the fix ($_FILES is empty) and passes after.

Note: I found this through source inspection with an automated/LLM-assisted tool, then reproduced and verified it myself.

skip_upload was declared outside the multipart while loop and never reset between parts, so a single file part with
      malformed brackets caused all subsequent valid file parts in the same request to be silently skipped.
@hohphu8
hohphu8 requested a review from bukka as a code owner November 26, 2026 04:27
Copilot AI balanced review requested due to automatic review settings November 26, 2026 04:27

This comment was marked as off-topic.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants