-
Notifications
You must be signed in to change notification settings - Fork 619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reduce size limit for scanline files; prevent large chunkoffset allocations #824
reduce size limit for scanline files; prevent large chunkoffset allocations #824
Conversation
…et allocations Signed-off-by: Peter Hillman <[email protected]>
Signed-off-by: Peter Hillman <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Signed-off-by: Peter Hillman <[email protected]>
…into memorylimit
Moving the test earlier in the function should also address https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25156 |
OpenEXR/IlmImf/ImfMisc.h
Outdated
// return the number of scanlines in each chunk of a scanlineimage for the given scheme | ||
// | ||
IMF_EXPORT int | ||
numLinesInBuffer(Compression comp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is declared in ImfCompressor.h, does it need to be declared here, too?
// | ||
// avoid allocating excessive memory. | ||
// If the chunktablesize claims to be large, | ||
// check the file is big enough to contain the file before allocating memory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean "file is big enough to contain the file"? And is the trick here that the read with throw an exception if the size is off? If so, it would be good to state that's the expectation.
Same comment in ImfScanLineInputFile below, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catches: Dumb typing errors. It should make more sense now
Signed-off-by: Peter Hillman <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…ations (AcademySoftwareFoundation#824) * reduce size limit for scanline files; protect against large chunkoffset allocations Signed-off-by: Peter Hillman <[email protected]> * bugfix for memory limit changes Signed-off-by: Peter Hillman <[email protected]> * rearrange chunkoffset test to protect bytesperline table too Signed-off-by: Peter Hillman <[email protected]> * remove extraneous function declaration; tidy comments Signed-off-by: Peter Hillman <[email protected]> Signed-off-by: Cary Phillips <[email protected]>
…ations (AcademySoftwareFoundation#824) * reduce size limit for scanline files; protect against large chunkoffset allocations Signed-off-by: Peter Hillman <[email protected]> * bugfix for memory limit changes Signed-off-by: Peter Hillman <[email protected]> * rearrange chunkoffset test to protect bytesperline table too Signed-off-by: Peter Hillman <[email protected]> * remove extraneous function declaration; tidy comments Signed-off-by: Peter Hillman <[email protected]> Signed-off-by: Cary Phillips <[email protected]>
* double-check unpackedBuffer created in DWA uncompress Signed-off-by: Peter Hillman <[email protected]> Signed-off-by: Cary Phillips <[email protected]> * compute Huf codelengths using 64 bit to prevent shift overflow Signed-off-by: Peter Hillman <[email protected]> Signed-off-by: Cary Phillips <[email protected]> * Avoid overflow in calculateNumTiles when size=MAX_INT (#825) * Avoid overflow in calculateNumTiles when size=MAX_INT Signed-off-by: Cary Phillips <[email protected]> * Compute level size with 64 bits to avoid overflow Signed-off-by: Cary Phillips <[email protected]> * More efficient handling of filled channels reading tiles with scanline API (#830) * refactor channel filling in InputFile API with tiled source Signed-off-by: Peter Hillman <[email protected]> * handle edge-case of empty framebuffer Signed-off-by: Peter Hillman <[email protected]> Signed-off-by: Cary Phillips <[email protected]> * fix undefined behavior: ignore unused bits in B44 mode detection (#832) Signed-off-by: Peter Hillman <[email protected]> Signed-off-by: Cary Phillips <[email protected]> * Fix overflow computing deeptile sample table size (#861) Signed-off-by: Peter Hillman <[email protected]> Signed-off-by: Cary Phillips <[email protected]> * sanity check ScanlineInput bytesPerLine instead of lineOffset size (#863) Signed-off-by: Peter Hillman <[email protected]> Co-authored-by: Cary Phillips <[email protected]> Signed-off-by: Cary Phillips <[email protected]> * Release notes for v2.4.3 Signed-off-by: Cary Phillips <[email protected]> * Bump version for v2.4.3 Signed-off-by: Cary Phillips <[email protected]> * reduce size limit for scanline files; prevent large chunkoffset allocations (#824) * reduce size limit for scanline files; protect against large chunkoffset allocations Signed-off-by: Peter Hillman <[email protected]> * bugfix for memory limit changes Signed-off-by: Peter Hillman <[email protected]> * rearrange chunkoffset test to protect bytesperline table too Signed-off-by: Peter Hillman <[email protected]> * remove extraneous function declaration; tidy comments Signed-off-by: Peter Hillman <[email protected]> Signed-off-by: Cary Phillips <[email protected]> * Change v2.4.3 release date to May 17, and clean up urls Signed-off-by: Cary Phillips <[email protected]> Co-authored-by: Peter Hillman <[email protected]>
This change introduces a new function into the API
Specially crafted OpenEXR files can cause large amounts of memory to be allocated by the library when reading code, even if the file is very small. This PR proposes two ways to mitigate this:
It is not known if any legitimate EXRs exist that have more than 2GB of uncompressed data per scanline chunk. If so, they will rely on effective compression to prevent the compressed data size exceeding 2GB. Such files will have many channels (in which case using multiple parts would be more appropriate) or very wide scanlines (in which case tiled images would be more appropriate). Uncompressed files, and zip-single compressed files, are not affected by this change.
This PR moves
int numLinesInBuffer(Compression comp)
into ImfCompressor.h and makes it part of the API. It previously was in an anonymous namespace.Addresses the following oss-fuzz issues:
Signed-off-by: Peter Hillman [email protected]