You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2020/10/01 09:23:37 UTC

[tomcat] branch 9.0.x updated (e44fd93 -> e2f9266)

This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git.


    from e44fd93  Fix 64735 ServletContext.addJspFile() always fails with SecurityManager
     new 4885c00  Refactor: remove unused parameter, separate frame create and frame write
     new e2f9266  Fix BufferOverflowException reported on users list

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/tomcat/util/net/SocketBufferHandler.java    | 11 +++++++++++
 test/org/apache/coyote/http2/Http2TestBase.java        | 18 ++++++++----------
 test/org/apache/coyote/http2/TestHttp2Section_6_8.java |  2 +-
 webapps/docs/changelog.xml                             |  5 +++++
 4 files changed, 25 insertions(+), 11 deletions(-)


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 02/02: Fix BufferOverflowException reported on users list

Posted by ma...@apache.org.
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

commit e2f9266306efc79c4171e1a49cb20d41b8f0f036
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Oct 1 10:21:17 2020 +0100

    Fix BufferOverflowException reported on users list
---
 java/org/apache/tomcat/util/net/SocketBufferHandler.java | 11 +++++++++++
 webapps/docs/changelog.xml                               |  5 +++++
 2 files changed, 16 insertions(+)

diff --git a/java/org/apache/tomcat/util/net/SocketBufferHandler.java b/java/org/apache/tomcat/util/net/SocketBufferHandler.java
index d066240..78adf30 100644
--- a/java/org/apache/tomcat/util/net/SocketBufferHandler.java
+++ b/java/org/apache/tomcat/util/net/SocketBufferHandler.java
@@ -27,6 +27,17 @@ public class SocketBufferHandler {
         @Override
         public void expand(int newSize) {
         }
+        /*
+         * Http2AsyncParser$FrameCompletionHandler will return incomplete
+         * frame(s) to the buffer. If the previous frame (or concurrent write to
+         * a stream) triggered a connection close this call would fail with a
+         * BufferOverflowException as data can't be returned to a buffer of zero
+         * length. Override the method and make it a NO-OP to avoid triggering
+         * the exception.
+         */
+        @Override
+        public void unReadReadBuffer(ByteBuffer returnedData) {
+        }
     };
 
     private volatile boolean readBufferConfiguredForWrite = true;
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 08a8aad..65c8e01 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -140,6 +140,11 @@
         Don't send the Keep-Alive response header if the connection has been
         explicitly closed. (markt)
       </fix>
+      <fix>
+        Avoid a <code>BufferOverflowException</code> if an HTTP/2 connection is
+        closed while the parser still has a partial HTTP/2 frame in the input
+        buffer. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 01/02: Refactor: remove unused parameter, separate frame create and frame write

Posted by ma...@apache.org.
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

commit 4885c00f2c27be5fdb53bdd55a7ba3c42e9edb6d
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Oct 1 10:18:01 2020 +0100

    Refactor: remove unused parameter, separate frame create and frame write
---
 test/org/apache/coyote/http2/Http2TestBase.java        | 18 ++++++++----------
 test/org/apache/coyote/http2/TestHttp2Section_6_8.java |  2 +-
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/test/org/apache/coyote/http2/Http2TestBase.java b/test/org/apache/coyote/http2/Http2TestBase.java
index ca72aed..1d1fee5 100644
--- a/test/org/apache/coyote/http2/Http2TestBase.java
+++ b/test/org/apache/coyote/http2/Http2TestBase.java
@@ -810,14 +810,9 @@ public abstract class Http2TestBase extends TomcatBaseTest {
     }
 
 
-    void sendGoaway(int streamId, int lastStreamId, long errorCode, byte[] debug)
-            throws IOException {
+    byte[] buildGoaway(int streamId, int lastStreamId, long errorCode) {
         byte[] goawayFrame = new byte[17];
-        int len = 8;
-        if (debug != null) {
-            len += debug.length;
-        }
-        ByteUtil.setThreeBytes(goawayFrame, 0, len);
+        ByteUtil.setThreeBytes(goawayFrame, 0, 8);
         // Type
         goawayFrame[3] = FrameType.GOAWAY.getIdByte();
         // No flags
@@ -826,10 +821,13 @@ public abstract class Http2TestBase extends TomcatBaseTest {
         // Last stream
         ByteUtil.set31Bits(goawayFrame, 9, lastStreamId);
         ByteUtil.setFourBytes(goawayFrame, 13, errorCode);
+        return goawayFrame;
+    }
+
+
+    void sendGoaway(int streamId, int lastStreamId, long errorCode) throws IOException {
+        byte[] goawayFrame = buildGoaway(streamId, lastStreamId, errorCode);
         os.write(goawayFrame);
-        if (debug != null && debug.length > 0) {
-            os.write(debug);
-        }
         os.flush();
     }
 
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_6_8.java b/test/org/apache/coyote/http2/TestHttp2Section_6_8.java
index c43a0b5..b80b1a9 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_6_8.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_6_8.java
@@ -76,7 +76,7 @@ public class TestHttp2Section_6_8 extends Http2TestBase {
         // HTTP2 upgrade
         http2Connect();
 
-        sendGoaway(1, 1, Http2Error.NO_ERROR.getCode(), null);
+        sendGoaway(1, 1, Http2Error.NO_ERROR.getCode());
 
         handleGoAwayResponse(1);
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org