[ 
https://issues.apache.org/jira/browse/PDFBOX-6384?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Maruan Sahyoun updated PDFBOX-6384:
-----------------------------------
    Description: 
This is a follow-up to PDFBOX-6265, which limited the row length for predictor 
decoding.

The row length is calculated as `int` from `/Colors`, `/BitsPerComponent` and 
`/Columns` in the decode parameters. Large values can overflow, e.g. `/Columns 
536870913` with 8 bits per pixel results in a row length of 1, which passes the 
checks for non-positive row lengths and for the maximum row length. Negative 
`/Colors` and `/BitsPerComponent` give a positive product as well. Decoding 
then works with parameters that don't match the row buffers, and can end with 
an `ArrayIndexOutOfBoundsException` instead of an `IOException`.

Proposed change
 - Calculate the predictor row length as `long`, and treat non-positive colors, 
bits per component or columns as a row length of 0, which is rejected
 - Check the row length against the maximum before converting it to `int`
 - Add tests for the maximum row length, an overflowing row length and negative 
parameters

Thanks to Gjoko Krstikj (ING) for the report.

Claude on behalf of Maruan Sahyoun (msahyoun)

  was:
This is a follow-up to PDFBOX-6265, which limited the row length for predictor 
decoding.

The row length is calculated as `int` from `/Colors`, `/BitsPerComponent` and 
`/Columns` in the decode parameters. Large values can overflow, e.g. `/Columns 
536870913` with 8 bits per pixel results in a row length of 1, which passes the 
checks for non-positive row lengths and for the maximum row length. Negative 
`/Colors` and `/BitsPerComponent` give a positive product as well. Decoding 
then works with parameters that don't match the row buffers, and can end with 
an `ArrayIndexOutOfBoundsException` instead of an `IOException`.

## Proposed change
- Calculate the predictor row length as `long`, and treat non-positive colors, 
bits per component or columns as a row length of 0, which is rejected
- Check the row length against the maximum before converting it to `int`
- Add tests for the maximum row length, an overflowing row length and negative 
parameters

Thanks to Gjoko Krstikj (ING) for the report.

Claude on behalf of Maruan Sahyoun (msahyoun)


> Calculate the predictor row length without int overflow
> -------------------------------------------------------
>
>                 Key: PDFBOX-6384
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-6384
>             Project: PDFBox
>          Issue Type: Bug
>            Reporter: Maruan Sahyoun
>            Priority: Minor
>
> This is a follow-up to PDFBOX-6265, which limited the row length for 
> predictor decoding.
> The row length is calculated as `int` from `/Colors`, `/BitsPerComponent` and 
> `/Columns` in the decode parameters. Large values can overflow, e.g. 
> `/Columns 536870913` with 8 bits per pixel results in a row length of 1, 
> which passes the checks for non-positive row lengths and for the maximum row 
> length. Negative `/Colors` and `/BitsPerComponent` give a positive product as 
> well. Decoding then works with parameters that don't match the row buffers, 
> and can end with an `ArrayIndexOutOfBoundsException` instead of an 
> `IOException`.
> Proposed change
>  - Calculate the predictor row length as `long`, and treat non-positive 
> colors, bits per component or columns as a row length of 0, which is rejected
>  - Check the row length against the maximum before converting it to `int`
>  - Add tests for the maximum row length, an overflowing row length and 
> negative parameters
> Thanks to Gjoko Krstikj (ING) for the report.
> Claude on behalf of Maruan Sahyoun (msahyoun)



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

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

Reply via email to