From fb07bdf159910ec9e660f884413c60c1335666e0 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 7 Jul 2020 11:42:16 +0200 Subject: [PATCH] Issue #4967 - Possible buffer corruption in HTTP/2 session failures. Fixed test failure after merge. Made sure the lastStreamId is updated when resetting a new stream since it has been seen by the server and handled. This avoids that a new stream arriving during shutdown is interpreted as a connection failure, therefore failing all pending streams - we want them to complete. Signed-off-by: Simone Bordet --- .../src/main/java/org/eclipse/jetty/http2/HTTP2Session.java | 6 +++--- .../org/eclipse/jetty/http2/server/HTTP2ServerSession.java | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java index d1eeb9a8f33..107cb15be93 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java @@ -693,14 +693,14 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio if (closed.compareAndSet(CloseState.NOT_CLOSED, CloseState.LOCALLY_CLOSED)) { if (LOG.isDebugEnabled()) - LOG.debug("Closing {}/{}", error, reason); + LOG.debug("Closing {}/{} {}", error, reason, this); closeFrame = newGoAwayFrame(CloseState.LOCALLY_CLOSED, error, reason); control(null, callback, closeFrame); return true; } if (LOG.isDebugEnabled()) - LOG.debug("Ignoring close {}/{}, already closed", error, reason); + LOG.debug("Ignoring close {}/{}, already closed {}", error, reason, this); callback.succeeded(); return false; } @@ -1151,7 +1151,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio return lastRemoteStreamId.get(); } - private void updateLastRemoteStreamId(int streamId) + protected void updateLastRemoteStreamId(int streamId) { Atomics.updateMax(lastRemoteStreamId, streamId); } diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerSession.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerSession.java index aa4cf8c43c7..3f91042fd30 100644 --- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerSession.java +++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerSession.java @@ -106,6 +106,7 @@ public class HTTP2ServerSession extends HTTP2Session implements ServerParser.Lis { if (isClosed()) { + updateLastRemoteStreamId(streamId); reset(new ResetFrame(streamId, ErrorCode.REFUSED_STREAM_ERROR.code), Callback.NOOP); } else