THausherr commented on code in PR #6:
URL: https://github.com/apache/pdfbox-jbig2/pull/6#discussion_r4501269774


##########
src/main/java/org/apache/pdfbox/jbig2/segments/PatternDictionary.java:
##########
@@ -125,6 +125,12 @@ private void checkInput() throws 
InvalidHeaderValueException
         {
             throw new InvalidHeaderValueException("Width/Heigth must be 
greater than zero.");
         }
+        // Guard the int arithmetic on grayMax: (grayMax + 1) is used as a 
collection
+        // capacity and (grayMax + 1) * hdpWidth as a bitmap width.
+        if (grayMax < 0 || ((long) grayMax + 1) * hdpWidth > Integer.MAX_VALUE)
+        {
+            throw new InvalidHeaderValueException("Invalid GRAYMAX value: " + 
grayMax);

Review Comment:
   No need to redesign the structure; having the bitmap exception getting 
triggered is fine, that is what it was added for.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to