Skip to content

Commit 0feed3d

Browse files
committed
Avoid potential IndexOutOfBoundsException when matching HTTP/2 preface. Submitted #551 by 刘文章.
1 parent 4d6f883 commit 0feed3d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

java/org/apache/coyote/http11/Http11InputBuffer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ boolean parseRequestLine(boolean keptAlive) throws IOException {
381381
// Switch to the socket timeout.
382382
wrapper.setReadTimeout(wrapper.getEndpoint().getConnectionTimeout());
383383
}
384-
if (!keptAlive && byteBuffer.position() == 0 && byteBuffer.limit() >= CLIENT_PREFACE_START.length - 1) {
384+
if (!keptAlive && byteBuffer.position() == 0 && byteBuffer.limit() >= CLIENT_PREFACE_START.length) {
385385
boolean prefaceMatch = true;
386386
for (int i = 0; i < CLIENT_PREFACE_START.length && prefaceMatch; i++) {
387387
if (CLIENT_PREFACE_START[i] != byteBuffer.get(i)) {

webapps/docs/changelog.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@
172172
the maximum value to 255. Based on a PR <pr>548</pr> by Stefan Mayr.
173173
(lihan)
174174
</fix>
175+
<fix>
176+
<pr>551</pr>: Avoid potential IndexOutOfBoundsException by fixing
177+
incorrect check when matching HTTP/2 preface. Submitted by 刘文章.
178+
(lihan)
179+
</fix>
175180
</changelog>
176181
</subsection>
177182
<subsection name="Jasper">

0 commit comments

Comments
 (0)