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 2015/06/08 23:07:38 UTC
svn commit: r1684279 - in /tomcat/trunk:
java/org/apache/coyote/http2/ByteUtil.java
test/org/apache/coyote/http2/TestHttp2Section_4_2.java
Author: markt
Date: Mon Jun 8 21:07:38 2015
New Revision: 1684279
URL: http://svn.apache.org/r1684279
Log:
Add a test for exceeding the maximum frame size
Modified:
tomcat/trunk/java/org/apache/coyote/http2/ByteUtil.java
tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_2.java
Modified: tomcat/trunk/java/org/apache/coyote/http2/ByteUtil.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/ByteUtil.java?rev=1684279&r1=1684278&r2=1684279&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/ByteUtil.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/ByteUtil.java Mon Jun 8 21:07:38 2015
@@ -61,6 +61,12 @@ public class ByteUtil {
}
+ public static void setTwoBytes(byte[] output, int firstByte, int value) {
+ output[firstByte] = (byte) ((value & 0xFF00) >> 8);
+ output[firstByte + 1] = (byte) (value & 0xFF);
+ }
+
+
public static void setThreeBytes(byte[] output, int firstByte, int value) {
output[firstByte] = (byte) ((value & 0xFF0000) >> 16);
output[firstByte + 1] = (byte) ((value & 0xFF00) >> 8);
Modified: tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_2.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_2.java?rev=1684279&r1=1684278&r2=1684279&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_2.java (original)
+++ tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_4_2.java Mon Jun 8 21:07:38 2015
@@ -28,7 +28,42 @@ import org.junit.Test;
*/
public class TestHttp2Section_4_2 extends Http2TestBase {
- // TODO Exceeds SETTINGS_MAX_FRAME_SIZE
+ @Test
+ public void testFrameSizeLimitsTooBig() throws Exception {
+ hpackEncoder = new HpackEncoder(ConnectionSettings.DEFAULT_HEADER_TABLE_SIZE);
+
+ // HTTP2 upgrade
+ http2Connect();
+
+ // Overly large settings
+ // Settings have to be a multiple of six
+ int settingsCount = (ConnectionSettings.DEFAULT_MAX_FRAME_SIZE / 6) + 1;
+ int size = settingsCount * 6;
+ byte[] settings = new byte[size + 9];
+ // Header
+ // Length
+ ByteUtil.setThreeBytes(settings, 0, size);
+ // Type
+ settings[3] = FrameType.SETTINGS.getIdByte();
+ // No flags
+ // Stream 0
+
+ // payload
+ for (int i = 0; i < settingsCount; i++) {
+ // Enable server push over and over again
+ ByteUtil.setTwoBytes(settings, (i * 6) + 9, 2);
+ ByteUtil.setFourBytes(settings, (i * 6) + 9 + 2, 1);
+ }
+
+ os.write(settings);
+
+ // Read GOAWAY frame
+ parser.readFrame(true);
+
+ Assert.assertTrue(output.getTrace(),
+ output.getTrace().startsWith("0-Goaway-[2147483647]-[" +
+ Error.FRAME_SIZE_ERROR.getCode() + "]-["));
+ }
@Test
public void testFrameTypeLimitsTooBig() throws Exception {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org