Skip to content

Commit 783b654

Browse files
Reject short zlib inflates before pixel unpack. (#2547)
DWA UNKNOWN: pass actual_out to exr_uncompress_buffer() and require the inflated byte count to match UNKNOWN_UNCOMPRESSED_SIZE before copying planar data to output rows. ZIP/ZIPS: require actual_out_bytes to equal the expected uncompressed chunk size before reconstructing and unpacking pixels. Addresses https://github.com/AcademySoftwareFoundation/openexr/security/advisories/GHSA-38j8-88v6-jrm7 Addresses https://github.com/AcademySoftwareFoundation/openexr/security/advisories/GHSA-r864-gwqv-q2hp Signed-off-by: Cary Phillips <seabeepea@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent c07a0f1 commit 783b654

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

src/lib/OpenEXRCore/internal_dwa_compressor.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -873,18 +873,21 @@ DwaCompressor_uncompress (
873873

874874
if (unknownCompressedSize > 0)
875875
{
876+
size_t actualUnknown;
877+
876878
if (unknownUncompressedSize > me->_planarUncBufferSize[UNKNOWN])
877879
{
878880
return EXR_ERR_CORRUPT_CHUNK;
879881
}
880882

881-
if (EXR_ERR_SUCCESS != exr_uncompress_buffer (
882-
me->_decode->context,
883-
compressedUnknownBuf,
884-
unknownCompressedSize,
885-
me->_planarUncBuffer[UNKNOWN],
886-
unknownUncompressedSize,
887-
NULL))
883+
rv = exr_uncompress_buffer (
884+
me->_decode->context,
885+
compressedUnknownBuf,
886+
unknownCompressedSize,
887+
me->_planarUncBuffer[UNKNOWN],
888+
unknownUncompressedSize,
889+
&actualUnknown);
890+
if (rv != EXR_ERR_SUCCESS || actualUnknown != unknownUncompressedSize)
888891
{
889892
return EXR_ERR_CORRUPT_CHUNK;
890893
}

src/lib/OpenEXRCore/internal_zip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ undo_zip_impl (
313313
if (res == EXR_ERR_SUCCESS)
314314
{
315315
decode->bytes_decompressed = actual_out_bytes;
316-
if (comp_buf_size > actual_out_bytes || actual_out_bytes > uncompressed_size)
316+
if (actual_out_bytes != uncompressed_size)
317317
res = EXR_ERR_CORRUPT_CHUNK;
318318
else
319319
internal_zip_reconstruct_bytes (

0 commit comments

Comments
 (0)