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

 ##########
 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 am certain that the specification is referring to bytes on the wire, not 
the internal in-memory representation, which the peer cannot possibly know. 
Furthermore, due to [JEP 254](https://openjdk.java.net/jeps/254), modern JVMs 
now use one byte per character to represent most strings.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to