Skip to content

http: stop dropping large custom headers - #22336

Closed
GrahamCampbell wants to merge 2 commits into
curl:masterfrom
GrahamCampbell:fix-oversized-custom-header
Closed

http: stop dropping large custom headers#22336
GrahamCampbell wants to merge 2 commits into
curl:masterfrom
GrahamCampbell:fix-oversized-custom-header

Conversation

@GrahamCampbell

Copy link
Copy Markdown
Contributor

Custom request headers larger than the response-header parser limit have been silently omitted or misinterpreted since curl 8.13.0 because outbound parsing treats a bounded-parser failure as an empty field. This restores delimiter-based parsing for custom fields and token checks, transmits fields that fit each destination request buffer, and returns CURLE_TOO_LARGE when a request cannot fit.

@github-actions github-actions Bot added the tests label Jul 16, 2026
@GrahamCampbell
GrahamCampbell force-pushed the fix-oversized-custom-header branch from 36ca2b8 to 20ac3b3 Compare July 16, 2026 12:36
@bagder
bagder requested a review from Copilot July 20, 2026 22:26

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 fixes HTTP custom request header handling so that very large user-provided headers are no longer silently dropped/misparsed due to reuse of the response-header parser size limit, and instead are correctly parsed/sent up to the request buffer limit (failing with CURLE_TOO_LARGE when the request cannot fit).

Changes:

  • Switch header value/token parsing in lib/http.c from bounded “response header size” parsing to delimiter-based parsing for custom/outbound header handling.
  • Ensure blank custom headers ("Name;" form) are appended without integer truncation risks for long header names.
  • Add regression tests covering: (1) large custom headers that should be transmitted, and (2) oversized custom headers that must fail with CURLE_TOO_LARGE.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lib/http.c Adjusts header parsing and custom header emission to handle large outbound headers correctly and fail when exceeding request buffer limits.
tests/unit/unit1625.c Extends unit coverage for Curl_compareheader() to succeed with very large header values.
tests/data/test3228 New HTTP test verifying large custom request headers (over response-header limit) are still transmitted.
tests/data/test3229 New HTTP test verifying an oversized custom request header fails with CURLE_TOO_LARGE.
tests/data/Makefile.am Registers the new test cases in the test suite.

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

@bagder bagder closed this in 5bb7d7a Jul 20, 2026
@GrahamCampbell
GrahamCampbell deleted the fix-oversized-custom-header branch July 20, 2026 23:02
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.

3 participants