You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by GitBox <gi...@apache.org> on 2019/12/28 18:19:37 UTC

[GitHub] [httpcomponents-core] rschmitt commented on a change in pull request #174: Development

rschmitt commented on a change in pull request #174: Development
URL: https://github.com/apache/httpcomponents-core/pull/174#discussion_r361807359
 
 

 ##########
 File path: httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackDecoder.java
 ##########
 @@ -287,13 +290,25 @@ public Header decodeHeader(final ByteBuffer src) throws HPackException {
     }
 
     public List<Header> decodeHeaders(final ByteBuffer src) throws HPackException {
+        final boolean enforceSizeLimit = maxListSize < Integer.MAX_VALUE;
+        int listSize = 0;
 
         final List<Header> list = new ArrayList<>();
         while (src.hasRemaining()) {
             final Header header = decodeHeader(src);
             if (header == null) {
                 break;
             }
+            if (enforceSizeLimit) {
+                listSize += header.getName().length() * 2;
+                if (header.getValue() != null) {
+                    listSize += header.getValue().length() * 2;
+                }
+                listSize += 32;
 
 Review comment:
   I don't like how this code duplicates logic and constants from `HPackHeader`. Also, why are you multiplying everything by `2`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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