File openexr-CVE-2021-45942.patch of Package openexr.22327
Index: openexr-2.1.0/IlmImf/ImfDeepScanLineInputFile.cpp
===================================================================
--- openexr-2.1.0.orig/IlmImf/ImfDeepScanLineInputFile.cpp 2022-01-05 13:49:06.147093718 +0100
+++ openexr-2.1.0/IlmImf/ImfDeepScanLineInputFile.cpp 2022-01-05 13:49:16.639154654 +0100
@@ -70,6 +70,7 @@
#include <assert.h>
#include <limits>
+#include <inttypes.h>
#include "ImfNamespace.h"
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
@@ -1868,13 +1869,18 @@ readSampleCountForLineBlock(InputStreamM
// @TODO refactor the compressor code to ensure full 64-bit support.
//
- int compressorMaxDataSize = std::numeric_limits<int>::max();
- if (sampleCountTableDataSize > Int64(compressorMaxDataSize))
+ uint64_t compressorMaxDataSize = static_cast<uint64_t>(std::numeric_limits<int>::max());
+ if (packedDataSize > compressorMaxDataSize ||
+ unpackedDataSize > compressorMaxDataSize ||
+ sampleCountTableDataSize > compressorMaxDataSize)
{
THROW (IEX_NAMESPACE::ArgExc, "This version of the library does not "
<< "support the allocation of data with size > "
<< compressorMaxDataSize
- << " file table size :" << sampleCountTableDataSize << ".\n");
+ << " file table size :" << sampleCountTableDataSize
+ << " file unpacked size :" << unpackedDataSize
+ << " file packed size :" << packedDataSize
+ << ".\n");
}
streamData->is->read(data->sampleCountTableBuffer, sampleCountTableDataSize);