Maruan Sahyoun created PDFBOX-6385:
--------------------------------------
Summary: Allocate the sample table of type 0 functions from the
sample data
Key: PDFBOX-6385
URL: https://issues.apache.org/jira/browse/PDFBOX-6385
Project: PDFBox
Issue Type: Bug
Reporter: Maruan Sahyoun
The sample table of a type 0 (sampled) function is allocated with the size
declared by `/Size` and the number of output values, before the sample stream
is read. The `/Size` entries come from the document, so a small function
dictionary with e.g. `/Size [100000000]` and 8 output values makes PDFBox
allocate several gigabytes when the function is evaluated for the first time,
e.g. for a shading. The product of the `/Size` entries is also calculated as
`int`, and an overflow results in an `ArrayIndexOutOfBoundsException` when the
function is evaluated.
If the sample stream is shorter than declared, the missing samples are 0 and an
error is logged. This is kept, but the missing samples don't need to be
allocated.
Proposed change
- Read the sample stream first and allocate only the samples that are in it,
not all samples declared by `/Size`
- Return 0 for samples that are missing in the stream, as before
- Calculate the number of declared samples as `long`
Found by a Claude security scan.
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]