Skip to content

dynhds: check size overflows - #23210

Closed
icing wants to merge 3 commits into
curl:masterfrom
icing:dynhds-overflow-checks
Closed

icing wants to merge 3 commits into
curl:masterfrom
icing:dynhds-overflow-checks

Conversation

@icing

@icing icing commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

When adding headers, check arguments and make sure lengths do not overflow size_t calculations.

When formatting headers, use individual dynbuf adds instead of %.*s formats that require int casts.

reported-by: Joshua Rogers

@icing
icing requested a review from bagder October 1, 2026 10:11
Comment thread lib/dynhds.c Resolved
Comment thread lib/dynhds.c Resolved
@github-actions github-actions Bot added the tests label Oct 2, 2026
@curl curl deleted a comment from testclutch Oct 2, 2026
@bagder
bagder requested a balanced review from Copilot October 3, 2026 21:34

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.

Copilot review overview

🟡 Changes recommended

The C-string wrapper still dereferences a NULL name, and overflow boundaries lack regression coverage.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

Adds overflow-safe dynamic header handling and removes unsafe integer casts during formatting.

Changes:

  • Validates header arguments and size calculations.
  • Supports NULL zero-length values.
  • Formats headers through bounded dynbuf appends.
File Description
lib/​dynhds.c Adds validation, overflow checks, and safer formatting.
tests/​unit/​unit2602.c Tests NULL empty header values.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/dynhds.c Resolved
Comment thread lib/dynhds.c Resolved
icing added 3 commits October 5, 2026 08:45
When adding headers, check arguments and make sure lengths do
not overflow size_t calculations.

When formatting headers, use individual dynbuf adds instead
of %.*s formats that require int casts.

reported-by: Joshua Rogers
Also, provide for adding 0-length value with NULL.
Add unit tests for that.
- check name param on cadd
- add test for overflow prevention
@icing
icing force-pushed the dynhds-overflow-checks branch from 4fa7bba to e23062c Compare October 5, 2026 06:51
@icing
icing requested a review from bagder October 5, 2026 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

4 participants