Skip to content

Commit

Permalink
prevent invalid Compression enum values being read from file
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
  • Loading branch information
peterhillman authored and cary-ilm committed Aug 9, 2020
1 parent 9073608 commit 88420f9
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions OpenEXR/IlmImf/ImfCompressionAttribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,28 @@ CompressionAttribute::readValueFrom (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &is
{
unsigned char tmp;
Xdr::read <StreamIO> (is, tmp);

//
// prevent invalid values being written to Compressin enum
// by forcing all unknown types to NUM_COMPRESSION_METHODS which is also an invalid
// pixel type, but can be used as a PixelType enum value
// (Header::sanityCheck will throw an exception when files with invalid Compression types are read)
//

if (tmp!= NO_COMPRESSION &&
tmp != RLE_COMPRESSION &&
tmp != ZIPS_COMPRESSION &&
tmp != ZIP_COMPRESSION &&
tmp != PIZ_COMPRESSION &&
tmp != PXR24_COMPRESSION &&
tmp != B44_COMPRESSION &&
tmp != B44A_COMPRESSION &&
tmp != DWAA_COMPRESSION &&
tmp != DWAB_COMPRESSION)
{
tmp = NUM_COMPRESSION_METHODS;
}

_value = Compression (tmp);
}

Expand Down

0 comments on commit 88420f9

Please sign in to comment.