Skip to content

Commit fd6bbaa

Browse files
authored
validate that the uncompressed sizes recorded in the dwa header are valid (#2383)
This prevents some corruption when filling buffers where these sizes were trusted but not fully validated to be sane ahead of time Signed-off-by: Kimball Thurston <kdt3rd@gmail.com>
1 parent 0592ee5 commit fd6bbaa

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/lib/OpenEXRCore/internal_dwa_compressor.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,17 @@ DwaCompressor_uncompress (
769769
return EXR_ERR_CORRUPT_CHUNK;
770770
}
771771

772+
/* check for overflow conditions in the unc sizes, corrupt file no
773+
need to check the rleUncompressedSize, the zipped rle data will
774+
be checked below */
775+
if (unknownUncompressedSize > uncompressed_size ||
776+
rleRawSize > uncompressed_size ||
777+
(unknownUncompressedSize + rleRawSize) > uncompressed_size ||
778+
totalAcUncompressedCount > uncompressed_size)
779+
{
780+
return EXR_ERR_CORRUPT_CHUNK;
781+
}
782+
772783
if ((int64_t) unknownUncompressedSize < 0 ||
773784
(int64_t) unknownCompressedSize < 0 || (int64_t) acCompressedSize < 0 ||
774785
(int64_t) dcCompressedSize < 0 || (int64_t) rleCompressedSize < 0 ||

0 commit comments

Comments
 (0)