hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1774335 - in /httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2: config/H2Config.java impl/nio/AbstractHttp2StreamMultiplexer.java
Date Wed, 14 Dec 2016 20:19:22 GMT
Author: olegk
Date: Wed Dec 14 20:19:21 2016
New Revision: 1774335

URL: http://svn.apache.org/viewvc?rev=1774335&view=rev
Log:
Better handling of HTTP/2 settings violations

Modified:
    httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/config/H2Config.java
    httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/config/H2Config.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/config/H2Config.java?rev=1774335&r1=1774334&r2=1774335&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/config/H2Config.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/config/H2Config.java
Wed Dec 14 20:19:21 2016
@@ -148,12 +148,13 @@ public class H2Config {
         }
 
         public Builder setInitialWindowSize(final int initialWindowSize) {
+            Args.positive(initialWindowSize, "Initial window size");
             this.initialWindowSize = initialWindowSize;
             return this;
         }
 
         public Builder setMaxFrameSize(final int maxFrameSize) {
-            Args.check(maxFrameSize >= FrameConsts.MIN_FRAME_SIZE && maxFrameSize
< FrameConsts.MAX_FRAME_SIZE, "Invalid max frame size");
+            Args.check(maxFrameSize >= FrameConsts.MIN_FRAME_SIZE && maxFrameSize
<= FrameConsts.MAX_FRAME_SIZE, "Invalid max frame size");
             this.maxFrameSize = maxFrameSize;
             return this;
         }

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java?rev=1774335&r1=1774334&r2=1774335&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
Wed Dec 14 20:19:21 2016
@@ -171,7 +171,7 @@ abstract class AbstractHttp2StreamMultip
     private int updateWindow(final AtomicInteger window, final int delta) throws ArithmeticException
{
         for (;;) {
             final int current = window.get();
-            final long newValue = current + delta;
+            final long newValue = (long) current + delta;
             if (Math.abs(newValue) > Integer.MAX_VALUE) {
                 throw new ArithmeticException("Update causes flow control window to exceed
" + Integer.MAX_VALUE);
             }
@@ -1061,13 +1061,21 @@ abstract class AbstractHttp2StreamMultip
                         hPackDecoder.setMaxTableSize(value);
                         break;
                     case MAX_CONCURRENT_STREAMS:
-                        configBuilder.setMaxConcurrentStreams(value);
+                        try {
+                            configBuilder.setMaxConcurrentStreams(value);
+                        } catch (IllegalArgumentException ex) {
+                            throw new H2ConnectionException(H2Error.PROTOCOL_ERROR, ex.getMessage());
+                        }
                         break;
                     case ENABLE_PUSH:
                         configBuilder.setPushEnabled(value == 1);
                         break;
                     case INITIAL_WINDOW_SIZE:
-                        configBuilder.setInitialWindowSize(value);
+                        try {
+                            configBuilder.setInitialWindowSize(value);
+                        } catch (IllegalArgumentException ex) {
+                            throw new H2ConnectionException(H2Error.PROTOCOL_ERROR, ex.getMessage());
+                        }
                         final int delta = value - remoteConfig.getInitialWindowSize();
                         if (delta != 0) {
                             updateOutputWindow(0, connOutputWindow, delta);
@@ -1085,10 +1093,18 @@ abstract class AbstractHttp2StreamMultip
                         }
                         break;
                     case MAX_FRAME_SIZE:
-                        configBuilder.setMaxFrameSize(value);
+                        try {
+                            configBuilder.setMaxFrameSize(value);
+                        } catch (IllegalArgumentException ex) {
+                            throw new H2ConnectionException(H2Error.PROTOCOL_ERROR, ex.getMessage());
+                        }
                         break;
                     case MAX_HEADER_LIST_SIZE:
-                        configBuilder.setMaxHeaderListSize(value);
+                        try {
+                            configBuilder.setMaxHeaderListSize(value);
+                        } catch (IllegalArgumentException ex) {
+                            throw new H2ConnectionException(H2Error.PROTOCOL_ERROR, ex.getMessage());
+                        }
                         break;
                 }
             }



Mime
View raw message