http: stop dropping large custom headers - #22336
Closed
GrahamCampbell wants to merge 2 commits into
Closed
Conversation
GrahamCampbell
force-pushed
the
fix-oversized-custom-header
branch
from
July 16, 2026 12:36
36ca2b8 to
20ac3b3
Compare
bagder
approved these changes
Jul 20, 2026
There was a problem hiding this comment.
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.cfrom 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_LARGEwhen a request cannot fit.