Skip to content

http-form: report real error for malformed h=/H= headers (fixes #954) - #1124

Merged
vanhauser-thc merged 1 commit into
vanhauser-thc:masterfrom
NPCmillionaire:fix/issue-954-header-error
Nov 8, 2026
Merged

vanhauser-thc merged 1 commit into
vanhauser-thc:masterfrom
NPCmillionaire:fix/issue-954-header-error

Conversation

@NPCmillionaire

Copy link
Copy Markdown
Contributor

What

Fixes #954.

A h=/H= header option whose value lacks a Name:Value colon separator — e.g. a raw cookie string like H=PHPSESSID=abc; filterData=xyz; — parses to an empty value, which add_header() rejects. The caller then printed:

[ERROR] Out of memory for HTTP headers (H).

...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 the h= and H= parsers:

  • no : separator present, and
  • empty header name or empty value

and emit an actionable error naming the offending option and the expected Name:Value format (noting that a literal colon in the value is escaped as \:). The out-of-memory message is now reserved for a genuine add_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; the Cookie header is sent to the server unchanged.

No change in behavior for well-formed headers.

🤖 Generated with Claude Code

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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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

@vanhauser-thc

Copy link
Copy Markdown
Owner

thanks

@vanhauser-thc
vanhauser-thc merged commit 95ca233 into vanhauser-thc:master Nov 8, 2026
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.

[ERROR] Out of memory for HTTP headers (H)

3 participants