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

 ##########
 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:
   @rschmitt How would you interpret the requirement below from section 6.5.2 
about length in **octets**? As far as I understand `char` representation in 
Java takes two octets.
   
   ```The value is based on the
   uncompressed size of header fields, including the length of the
   name and value **in octets** plus an overhead of 32 octets for each
   header field.
   ```

----------------------------------------------------------------
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