Skip to content

repair chunk size overflowing in parser - #2650

Merged
an-tao merged 2 commits into
drogonframework:masterfrom
marty1885:fix-chunked-overflow
Oct 30, 2026
Merged

an-tao merged 2 commits into
drogonframework:masterfrom
marty1885:fix-chunked-overflow

Conversation

@marty1885

Copy link
Copy Markdown
Member

If chunk-length is set to SIZE_MAX - 2, strtoull passes. But later in line 286, currentChunkLength_ + 2 overflows to 0, if(buf->readableBytes() >= (currentChunkLength_ + 2)) passes and access underneath overflows. This patch ensures that overflow is impossible.

@marty1885
marty1885 requested a balanced review from Copilot October 29, 2026 15:14

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.

🟢 Approval recommended

No active review issues are reported for the chunk-length overflow guard.

No open issues 🎉

What changed in this PR

This PR hardens HTTP response chunk parsing by rejecting chunk lengths that would overflow when adding the two-byte trailing delimiter.

Changes:

  • Adds a size_t upper-bound check alongside existing chunk-length validation.
  • Includes <limits> to obtain the platform-specific maximum value.
File Description
lib/​src/​HttpResponseParser.cc Rejects chunk lengths greater than SIZE_MAX - 2 to prevent overflow in subsequent buffer checks.

Review effort: Balanced

@marty1885
marty1885 requested a review from an-tao October 29, 2026 15:26
@an-tao
an-tao merged commit c432227 into drogonframework:master Oct 30, 2026
34 checks passed
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.

3 participants