Skip to content

Limit the length of content codec list that can be processed automatically#770

Merged
ok2c merged 1 commit into
apache:5.5.xfrom
ok2c:limit_codec_list_len
Dec 15, 2025
Merged

Limit the length of content codec list that can be processed automatically#770
ok2c merged 1 commit into
apache:5.5.xfrom
ok2c:limit_codec_list_len

Conversation

@ok2c

@ok2c ok2c commented Dec 15, 2025

Copy link
Copy Markdown
Member

I chose the default limit on 5 elements for no particular reason. I doubt even two compression codecs in the compression chain would be reasonable, so I chose 5 as 'crazy' enough for the majority of sane scenarios.

@arturobernalg Please rewiew

@ok2c ok2c requested a review from arturobernalg December 15, 2025 11:46

@arturobernalg arturobernalg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

final ParserCursor cursor = new ParserCursor(0, contentEncoding.length());
final HeaderElement[] codecs = BasicHeaderValueParser.INSTANCE.parseElements(contentEncoding, cursor);
if (maxCodecListLen > 0 && codecs.length > maxCodecListLen) {
throw new ProtocolException("Codec list exceeds maxumum of " + maxCodecListLen + " elements");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • “maxumum” → maximum
  • Should we validate maxCodecListLen and reject negative values with an IllegalArgumentException?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arturobernalg

“maxumum” → maximum

Corrected

Should we validate maxCodecListLen and reject negative values with an IllegalArgumentException?

This is an internal class. We control the input. If we ever make the class public, that would be a reasonable improvement

@ok2c ok2c force-pushed the limit_codec_list_len branch from 4d1b8ec to 7ab0fea Compare December 15, 2025 20:39
@ok2c ok2c merged commit 87d86a1 into apache:5.5.x Dec 15, 2025
8 checks passed
@ok2c ok2c deleted the limit_codec_list_len branch December 16, 2025 19:05
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.

2 participants