Skip to content

Fix HTTP startline validation (#16022)#16025

Merged
normanmaurer merged 1 commit into5.0from
h_5
Dec 13, 2025
Merged

Fix HTTP startline validation (#16022)#16025
normanmaurer merged 1 commit into5.0from
h_5

Conversation

@normanmaurer
Copy link
Member

Motivation:
The code assumed that oversized bit shifting would result in zeroing out values due to overflow. However, the Java Language Specification instead says that shifts effectively only consider the lower six bits of the shift amount, resulting in modular-arithmetic shifts. The consequence is that, for instance, shifing by the capital letter 'M' produces the same bit mask as carriage-return '\r', which is an illegal character in an HTTP start line. This incorrectly rejected valid URIs.

Modification:
Make the shifting conditional and only use it on character values less than or equal to 64 (the Long bit size). Also add tests to check that valid URLs are accepted.

Result:
Fixes #16020

Motivation:
The code assumed that oversized bit shifting would result in zeroing out
values due to overflow. However, the Java Language Specification instead
says that shifts effectively only consider the lower six bits of the
shift amount, resulting in modular-arithmetic shifts. The consequence is
that, for instance, shifing by the capital letter 'M' produces the same
bit mask as carriage-return '\r', which is an illegal character in an
HTTP start line. This incorrectly rejected valid URIs.

Modification:
Make the shifting conditional and only use it on character values less
than or equal to 64 (the Long bit size). Also add tests to check that
valid URLs are accepted.

Result:
Fixes #16020

---------

Co-authored-by: Jonas Konrad <me@yawk.at>
@normanmaurer normanmaurer added this to the 5.0.0.Final milestone Dec 13, 2025
@normanmaurer normanmaurer merged commit aa5b167 into 5.0 Dec 13, 2025
19 of 23 checks passed
@normanmaurer normanmaurer deleted the h_5 branch December 13, 2025 13:55
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