Make sure attachment-max-headers-count property is respected for repeated headers - #3430
Open
reta wants to merge 1 commit into
Open
Make sure attachment-max-headers-count property is respected for repeated headers#3430reta wants to merge 1 commit into
reta wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new header-count enforcement has an off-by-one that rejects exactly maxHeadersCount headers, and the new test includes an unused local variable.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates CXF’s MIME attachment header parsing so the configured attachment-max-headers-count limit is enforced based on the total number of header lines, including repeated header names.
Changes:
- Track and enforce the total number of collected attachment header lines (not just distinct header names).
- Add a regression test that constructs many repeated headers and expects parsing to fail when the configured maximum is exceeded.
File summaries
| File | Description |
|---|---|
| core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializerUtil.java | Counts total parsed header lines and throws when the attachment exceeds the configured header-count limit. |
| core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java | Adds a test case covering repeated headers exceeding the max header count. |
Review details
Suppressed comments (1)
core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializerUtil.java:127
- Same off-by-one issue when flushing the final pending header:
>= maxHeadersCountrejects a message with exactlymaxHeadersCountheaders.
if (buffer.length() > 0 && addHeaderLine(heads, buffer, maxHeadersCount, maxHeaderLength)) {
totalHeadersCollected += 1;
if (totalHeadersCollected >= maxHeadersCount) {
throw new IOException("The attachment contains more headers than are permitted");
}
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
reta
force-pushed
the
header.repeated.count
branch
from
September 1, 2026 23:51
a7bac2d to
0acbd48
Compare
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.
Make sure attachment-max-headers-count property is respected for repeated headers