sharanggupta opened a new pull request, #6:
URL: https://github.com/apache/pdfbox-jbig2/pull/6

   Several JBIG2 segment decoders size allocations directly from 32-bit header 
fields with no bounds check, so a malformed stream can overflow an `int` into 
an undersized backing array, or request a negative/huge allocation. These 
surface as `NegativeArraySizeException` / `OutOfMemoryError` out of 
`ImageIO.read` rather than a clean decode error. This adds overflow-safe bounds 
checks at four allocation sites, matching the project's existing validation 
style (`SymbolDictionary.getToExportFlags`, `PatternDictionary.checkInput`).
   
   - **Bitmap**: reject negative dimensions and sizes whose byte length 
overflows `int` (the overflow previously produced a zero-length backing array).
   - **SymbolDictionary**: validate the new/imported symbol counts before 
building the symbol array — the existing `getToExportFlags` check even notes 
the validation "could be placed a little earlier".
   - **PatternDictionary**: reject an invalid `GRAYMAX` before using `grayMax + 
1` as a collection capacity.
   - **HalftoneRegion**: validate the halftone grid dimensions before 
allocating.
   
   `BitmapTest` gains two cases for the constructor guard (both fail on 
`master`, pass with this change); the module compiles and the existing tests 
pass.
   
   GitHub issues are disabled on this repo, so I've raised this as a PR 
directly — happy to open a PDFBOX JIRA to track it if the team prefers.
   


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