Skip to content

tool_formparse: tool2curlparts is no longer recursive#21518

Closed
bagder wants to merge 2 commits into
masterfrom
bagder/formparse-norecurse
Closed

tool_formparse: tool2curlparts is no longer recursive#21518
bagder wants to merge 2 commits into
masterfrom
bagder/formparse-norecurse

Conversation

@bagder

@bagder bagder commented May 7, 2026

Copy link
Copy Markdown
Member

It could otherwise trigger a stack overflow in extreme cases

It could otherwise trigger a stack overflow in extreme cases
@github-actions github-actions Bot added the MIME label May 7, 2026
@bagder bagder marked this pull request as ready for review May 7, 2026 06:41
@bagder bagder requested a review from Copilot May 7, 2026 06:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates tool_formparse’s internal MIME-to-libcurl conversion to avoid deep recursion when walking long prev sibling chains, preventing potential stack overflows with extreme numbers of form parts.

Changes:

  • Reworked tool2curlparts() to traverse the struct tool_mime sibling list iteratively instead of recursively.
  • Added a temporary pointer array to preserve original part order while iterating.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/tool_formparse.c
@bagder bagder closed this in 98d818c May 7, 2026
@bagder bagder deleted the bagder/formparse-norecurse branch May 7, 2026 07:10
outcast36 pushed a commit to greearb/curl that referenced this pull request Jun 3, 2026
It could otherwise trigger a stack overflow in extreme cases

Reported-by: Andrew Nesbit
Closes curl#21518
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants