Repository navigation
http-form: report real error for malformed h=/H= headers (fixes #954) - #1124
Merged
vanhauser-thc merged 1 commit intoNov 8, 2026
Merged
vanhauser-thc merged 1 commit into
vanhauser-thc merged 1 commit into
Conversation
A header option whose value had no "Name:Value" colon separator (e.g. H=PHPSESSID=...; a raw cookie string) parsed to an empty value, which add_header() rejects. The caller then printed the misleading "[ERROR] Out of memory for HTTP headers (H)." leaving users chasing a non-existent memory problem (issue vanhauser-thc#954). Detect the two malformed cases in the h= and H= parsers and emit an actionable error naming the offending option and the expected "Name:Value" format (noting \: to escape a literal colon). The out-of-memory message is now reserved for a genuine add_header() allocation failure. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the malformed HTTP-form header diagnostic update.
No open issues 🎉
What changed in this PR
This PR addresses #954 by making HTTP-form header parsing report malformed h=/H= options as format errors rather than misleading out-of-memory errors.
Changes:
- Adds checks for missing colon separators and empty header names or values, with guidance on the expected format.
- Updates allocation-failure messages and documents the diagnostic improvement in the changelog.
| File | Description |
|---|---|
hydra-http-form.c |
Validates header options before adding them and reports specific format errors. |
CHANGES |
Records the malformed-header diagnostic fix for issue #954. |
Review effort: Balanced
Owner
|
thanks |
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.
What
Fixes #954.
A
h=/H=header option whose value lacks aName:Valuecolon separator — e.g. a raw cookie string likeH=PHPSESSID=abc; filterData=xyz;— parses to an empty value, whichadd_header()rejects. The caller then printed:...which sends users chasing a memory problem that doesn't exist. This is exactly what the reporter (and follow-up commenters) hit.
Change
In
parse_options(), detect the two malformed cases in both theh=andH=parsers::separator present, andand emit an actionable error naming the offending option and the expected
Name:Valueformat (noting that a literal colon in the value is escaped as\:). The out-of-memory message is now reserved for a genuineadd_header()allocation failure.Verification
Built locally and tested against the reproducing inputs:
H=PHPSESSID=abc123; filterData=xyz;(no colon) →[ERROR] invalid header 'H=PHPSESSID=abc123; filterData=xyz;': expected format "Name:Value" (escape a literal colon in the value as \:)H=X-Test\:(empty value) →[ERROR] invalid header 'H=...': header name and value must both be non-empty (use "Name:Value")H=Cookie:PHPSESSID=abc123; security=low(valid) → still accepted; theCookieheader is sent to the server unchanged.No change in behavior for well-formed headers.
🤖 Generated with Claude Code