Skip to content

header_rewrite: guard the i == 0 case in HRWSimpleTokenizer - #13672

Merged
masaori335 merged 2 commits into
apache:masterfrom
masaori335:asf-master-fix-header-rewrite-oob
Sep 15, 2026
Merged

masaori335 merged 2 commits into
apache:masterfrom
masaori335:asf-master-fix-header-rewrite-oob

Conversation

@masaori335

Copy link
Copy Markdown
Contributor

A value whose first character is '{' or '<' made the tokenizer read line[-1], so whether the config loaded or was rejected with an opaque "basic_string" error depended on the adjacent byte. Matches the guard parse_line already uses for the same idiom.

A value whose first character is '{' or '<' made the tokenizer read
line[-1], so whether the config loaded or was rejected with an opaque
"basic_string" error depended on the adjacent byte. Matches the guard
parse_line already uses for the same idiom.
@masaori335 masaori335 added this to the 11.0.0 milestone Sep 14, 2026
@masaori335 masaori335 self-assigned this Sep 14, 2026
Copilot AI lite review requested due to automatic review settings September 14, 2026 00:37
@masaori335 masaori335 added Bug header_rewrite header_rewrite plugin labels Sep 14, 2026

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

The only remaining comment is a minor test-coverage nit.

Pull request overview

Guards HRWSimpleTokenizer against out-of-bounds look-behind access at the start of a line.

Changes:

  • Adds an i > 0 check before accessing line[i - 1].
  • Adds regression coverage for a leading {.
File summaries
File Reviewed changes Review note
plugins/header_rewrite/parser.cc Adds the start-of-line guard.
plugins/header_rewrite/header_rewrite_test.cc Adds regression coverage for leading {. Nit (2 votes): also cover a leading <.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

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

Comment thread plugins/header_rewrite/header_rewrite_test.cc
The i == 0 guard protects both '{' and '<', but only the '{' form was
exercised.
Copilot AI review requested due to automatic review settings September 14, 2026 02:01

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

The fix and regression tests address the reported out-of-bounds access.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@bryancall
bryancall requested a review from JosiahWI September 14, 2026 21:30

@JosiahWI JosiahWI 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.

I could not find parse_line, but the fix looks good. Thank you!

@masaori335
masaori335 merged commit 9e26453 into apache:master Sep 15, 2026
14 checks passed
@github-project-automation github-project-automation Bot moved this to For v10.2.1 in ATS v10.2.x Sep 15, 2026
@masaori335

masaori335 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for checking. It's Parser::parse_line which makes sure the line[i-1] runs only if i >= 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug header_rewrite header_rewrite plugin

Projects

Status: For v10.2.1

Development

Successfully merging this pull request may close these issues.

3 participants