This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new 1e97ab2 Fix HTTP/2 window updates with zero padding. Found via CI tests 1e97ab2 is described below commit 1e97ab20677f7295db2bdaad3f294b1d553208ae Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu Oct 8 14:20:53 2020 +0100 Fix HTTP/2 window updates with zero padding. Found via CI tests --- java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java | 5 +++-- java/org/apache/coyote/http2/Http2UpgradeHandler.java | 11 +++++------ webapps/docs/changelog.xml | 9 +++++++++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java b/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java index 2068044..931de90 100644 --- a/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java +++ b/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java @@ -229,14 +229,15 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler { @Override - void writeWindowUpdate(Stream stream, int increment, boolean applicationInitiated) + void writeWindowUpdate(AbstractNonZeroStream stream, int increment, boolean applicationInitiated) throws IOException { // Build window update frame for stream 0 byte[] frame = new byte[13]; ByteUtil.setThreeBytes(frame, 0, 4); frame[3] = FrameType.WINDOW_UPDATE.getIdByte(); ByteUtil.set31Bits(frame, 9, increment); - if (stream.canWrite()) { + // No need to send update from closed stream + if (stream instanceof Stream && ((Stream) stream).canWrite()) { // Change stream Id byte[] frame2 = new byte[13]; ByteUtil.setThreeBytes(frame2, 0, 4); diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java b/java/org/apache/coyote/http2/Http2UpgradeHandler.java index a1002c1..79f2bad 100644 --- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java +++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java @@ -802,7 +802,7 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH * Needs to know if this was application initiated since that affects the * error handling. */ - void writeWindowUpdate(Stream stream, int increment, boolean applicationInitiated) + void writeWindowUpdate(AbstractNonZeroStream stream, int increment, boolean applicationInitiated) throws IOException { synchronized (socketWrapper) { // Build window update frame for stream 0 @@ -811,7 +811,8 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH frame[3] = FrameType.WINDOW_UPDATE.getIdByte(); ByteUtil.set31Bits(frame, 9, increment); socketWrapper.write(true, frame, 0, frame.length); - if (stream.canWrite()) { + // No need to send update from closed stream + if (stream instanceof Stream && ((Stream) stream).canWrite()) { // Change stream Id and re-use ByteUtil.set31Bits(frame, 5, stream.getIdAsInt()); try { @@ -1488,10 +1489,8 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH public void swallowedPadding(int streamId, int paddingLength) throws ConnectionException, IOException { AbstractNonZeroStream abstractNonZeroStream = getStreamMayBeClosed(streamId, true); - if (abstractNonZeroStream instanceof Stream) { - // +1 is for the payload byte used to define the padding length - writeWindowUpdate((Stream) abstractNonZeroStream, paddingLength + 1, false); - } + // +1 is for the payload byte used to define the padding length + writeWindowUpdate(abstractNonZeroStream, paddingLength + 1, false); } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 9ec9fca..07bdea9 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -56,6 +56,15 @@ </fix> </changelog> </subsection> + <subseciton name="Coyote"> + <changelog> + <fix> + Refactor the HTTP/2 window update handling for padding in data frames to + ensure that the connection window is correctly updated after a data + frame with zero lngth padding is received. (markt) + </fix> + </changelog> + </subseciton> <subsection name="Jasper"> <changelog> <fix> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org