Skip to content
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

Cherry-pick PR's into the RB-2.5 branch for v2.5.5 release #917

Merged
merged 15 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# OpenEXR Release Notes

* [Version 2.5.5](#version-255-february-12-2021) February 12, 2021
* [Version 2.5.4](#version-254-december-31-2020) December 31, 2020
* [Version 2.5.3](#version-253-august-12-2020) August 12, 2020
* [Version 2.5.2](#version-252-june-15-2020) June 15, 2020
Expand Down Expand Up @@ -38,8 +39,34 @@
* [Version 1.0.1](#version-101)
* [Version 1.0](#version-10)

## Version 2.5.4 (December 31, 2020)
## Version 2.5.5 (February 12, 2021)

Patch release with various bug/sanitizer/security fixes, primarily
related to reading corrupted input files, but also a fix for universal
build support on macOS.

Specific OSS-fuzz issues include:

* OSS-fuzz [#30291](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=30291)
* OSS-fuzz [#29106](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29106)
* OSS-fuzz [#28971](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28971)
* OSS-fuzz [#29829](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29829)
* OSS-fuzz [#30121](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=30121)

### Merged Pull Requests

* [#914](https://github.com/AcademySoftwareFoundation/openexr/pull/914) additional verification of DWA data sizes
* [#910](https://github.com/AcademySoftwareFoundation/openexr/pull/910) update tileoffset sanitycheck to handle ripmaps
* [#903](https://github.com/AcademySoftwareFoundation/openexr/pull/903) prevent overflows by using Int64 for all vars in DWA initialize
* [#901](https://github.com/AcademySoftwareFoundation/openexr/pull/901) Use size_t for DWA buffersize calculation
* [#897](https://github.com/AcademySoftwareFoundation/openexr/pull/897) prevent overflow in RgbaFile cachePadding
* [#896](https://github.com/AcademySoftwareFoundation/openexr/pull/896) add buffer size validation to FastHuf decode
* [#893](https://github.com/AcademySoftwareFoundation/openexr/pull/893) Include <limits> where required by newer compilers
* [#889](https://github.com/AcademySoftwareFoundation/openexr/pull/889) Add explicit #include <limits> for numeric_limits
* [#854](https://github.com/AcademySoftwareFoundation/openexr/pull/854) Fix Apple Universal 2 (arm64/x86_64) builds

## Version 2.5.4 (December 31, 2020)

Patch release with various bug/sanitizer/security fixes, primarily
related to reading corrupted input files.

Expand Down
25 changes: 25 additions & 0 deletions IlmBase/IlmThread/IlmThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ Thread::~Thread ()
_thread.join ();
}

void
Thread::join()
{
if ( _thread.joinable () )
_thread.join ();
}

bool
Thread::joinable() const
{
return _thread.joinable();
}

void
Thread::start ()
Expand Down Expand Up @@ -108,6 +120,19 @@ Thread::start ()
{
throw IEX_NAMESPACE::NoImplExc ("Threads not supported on this platform.");
}

void
Thread::join ()
{
throw IEX_NAMESPACE::NoImplExc ("Threads not supported / enabled on this platform.");
}

bool
Thread::joinable () const
{
throw IEX_NAMESPACE::NoImplExc ("Threads not supported / enabled on this platform.");
}

# endif
#endif

Expand Down
6 changes: 6 additions & 0 deletions IlmBase/IlmThread/IlmThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ class Thread
ILMTHREAD_EXPORT void start ();
ILMTHREAD_EXPORT virtual void run () = 0;

//
// wait for thread to exit - must be called before deleting thread
//
void join();
bool joinable() const;

private:

#ifdef ILMBASE_FORCE_CXX03
Expand Down
14 changes: 11 additions & 3 deletions IlmBase/IlmThread/IlmThreadPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,16 +423,24 @@ DefaultThreadPoolProvider::finish ()
size_t curT = _data.threads.size();
for (size_t i = 0; i != curT; ++i)
{
_data.taskSemaphore.post();
_data.threadSemaphore.wait();
if (_data.threads[i]->joinable())
{
_data.taskSemaphore.post();
_data.threadSemaphore.wait();
}
}

//
// Join all the threads
//
for (size_t i = 0; i != curT; ++i)
delete _data.threads[i];
{
if (_data.threads[i]->joinable())
_data.threads[i]->join();

delete _data.threads[i];
}

Lock lock1 (_data.taskMutex);
#ifdef ILMBASE_FORCE_CXX03
Lock lock2 (_data.stopMutex);
Expand Down
6 changes: 3 additions & 3 deletions IlmBase/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ dnl Copyright Contributors to the OpenEXR Project.
dnl

dnl Process this file with autoconf to produce a configure script.
AC_INIT(IlmBase, 2.5.4)
AC_INIT(IlmBase, 2.5.5)

AC_SUBST(ILMBASE_VERSION_MAJOR, 2)
AC_SUBST(ILMBASE_VERSION_MINOR, 5)
AC_SUBST(ILMBASE_VERSION_PATCH, 4)
AC_SUBST(ILMBASE_VERSION_PATCH, 5)

AC_SUBST(ILMBASE_VERSION, ${ILMBASE_VERSION_MAJOR}.${ILMBASE_VERSION_MINOR}.${ILMBASE_VERSION_PATCH})
AC_SUBST(ILMBASE_VERSION_API, ${ILMBASE_VERSION_MAJOR}_${ILMBASE_VERSION_MINOR})
Expand All @@ -22,7 +22,7 @@ AM_MAINTAINER_MODE


LIBTOOL_CURRENT=25
LIBTOOL_REVISION=3
LIBTOOL_REVISION=4
LIBTOOL_AGE=0
LIBTOOL_VERSION=$LIBTOOL_CURRENT:$LIBTOOL_REVISION:$LIBTOOL_AGE
AC_SUBST(LIBTOOL_VERSION)
Expand Down
5 changes: 2 additions & 3 deletions OpenEXR/IlmImf/ImfDeepScanLineInputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@

#include "Iex.h"

#include <algorithm>
#include <assert.h>
#include <string>
#include <vector>
#include <assert.h>
#include <limits>
#include <algorithm>


#include "ImfNamespace.h"
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
Expand Down
2 changes: 2 additions & 0 deletions OpenEXR/IlmImf/ImfDeepTiledInputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
#include <vector>
#include <algorithm>
#include <assert.h>
#include <string>
#include <vector>
#include <limits>

#include "ImfNamespace.h"
Expand Down
66 changes: 39 additions & 27 deletions OpenEXR/IlmImf/ImfDwaCompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2606,6 +2606,14 @@ DwaCompressor::uncompress
throw IEX_NAMESPACE::BaseExc("DC data corrupt.");
}
}
else
{
// if the compressed size is 0, then the uncompressed size must also be zero
if (totalDcUncompressedCount!=0)
{
throw IEX_NAMESPACE::BaseExc("DC data corrupt.");
}
}

//
// Uncompress the RLE data into _rleBuffer, then unRLE the results
Expand Down Expand Up @@ -2932,19 +2940,21 @@ DwaCompressor::initializeBuffers (size_t &outBufferSize)
// of channels we have.
//

int maxOutBufferSize = 0;
int numLossyDctChans = 0;
int unknownBufferSize = 0;
int rleBufferSize = 0;
Int64 maxOutBufferSize = 0;
Int64 numLossyDctChans = 0;
Int64 unknownBufferSize = 0;
Int64 rleBufferSize = 0;

int maxLossyDctAcSize = (int)ceil ((float)numScanLines() / 8.0f) *
(int)ceil ((float)(_max[0] - _min[0] + 1) / 8.0f) *
Int64 maxLossyDctAcSize = static_cast<Int64>(ceil ((float)numScanLines() / 8.0f)) *
static_cast<Int64>(ceil ((float)(_max[0] - _min[0] + 1) / 8.0f)) *
63 * sizeof (unsigned short);

int maxLossyDctDcSize = (int)ceil ((float)numScanLines() / 8.0f) *
(int)ceil ((float)(_max[0] - _min[0] + 1) / 8.0f) *
Int64 maxLossyDctDcSize = static_cast<Int64>(ceil ((float)numScanLines() / 8.0f)) *
static_cast<Int64>(ceil ((float)(_max[0] - _min[0] + 1) / 8.0f)) *
sizeof (unsigned short);

Int64 pixelCount = static_cast<Int64>(numScanLines()) * static_cast<Int64>(_max[0] - _min[0] + 1);

for (unsigned int chan = 0; chan < _channelData.size(); ++chan)
{
switch (_channelData[chan].compression)
Expand All @@ -2959,8 +2969,8 @@ DwaCompressor::initializeBuffers (size_t &outBufferSize)
//

maxOutBufferSize += std::max(
(int)(2 * maxLossyDctAcSize + 65536),
(int)compressBound (maxLossyDctAcSize) );
2lu * maxLossyDctAcSize + 65536lu,
static_cast<Int64>(compressBound (maxLossyDctAcSize)) );
numLossyDctChans++;
break;

Expand All @@ -2971,8 +2981,7 @@ DwaCompressor::initializeBuffers (size_t &outBufferSize)
// of the source data.
//

int rleAmount = 2 * numScanLines() * (_max[0] - _min[0] + 1) *
OPENEXR_IMF_NAMESPACE::pixelTypeSize (_channelData[chan].type);
Int64 rleAmount = 2 * pixelCount * OPENEXR_IMF_NAMESPACE::pixelTypeSize (_channelData[chan].type);

rleBufferSize += rleAmount;
}
Expand All @@ -2981,8 +2990,7 @@ DwaCompressor::initializeBuffers (size_t &outBufferSize)

case UNKNOWN:

unknownBufferSize += numScanLines() * (_max[0] - _min[0] + 1) *
OPENEXR_IMF_NAMESPACE::pixelTypeSize (_channelData[chan].type);
unknownBufferSize += pixelCount * OPENEXR_IMF_NAMESPACE::pixelTypeSize (_channelData[chan].type);
break;

default:
Expand All @@ -2999,13 +3007,13 @@ DwaCompressor::initializeBuffers (size_t &outBufferSize)
// which could take slightly more space
//

maxOutBufferSize += (int)compressBound ((uLongf)rleBufferSize);
maxOutBufferSize += static_cast<Int64>(compressBound (rleBufferSize));

//
// And the same goes for the UNKNOWN data
//

maxOutBufferSize += (int)compressBound ((uLongf)unknownBufferSize);
maxOutBufferSize += static_cast<Int64>(compressBound (unknownBufferSize));

//
// Allocate a zip/deflate compressor big enought to hold the DC data
Expand Down Expand Up @@ -3052,7 +3060,7 @@ DwaCompressor::initializeBuffers (size_t &outBufferSize)
// to Huffman encoding
//

if (static_cast<size_t>(maxLossyDctAcSize * numLossyDctChans) > _packedAcBufferSize)
if (maxLossyDctAcSize * numLossyDctChans > _packedAcBufferSize)
{
_packedAcBufferSize = maxLossyDctAcSize * numLossyDctChans;
if (_packedAcBuffer != 0)
Expand All @@ -3064,15 +3072,15 @@ DwaCompressor::initializeBuffers (size_t &outBufferSize)
// _packedDcBuffer holds one quantized DCT coef per 8x8 block
//

if (static_cast<size_t>(maxLossyDctDcSize * numLossyDctChans) > _packedDcBufferSize)
if (maxLossyDctDcSize * numLossyDctChans > _packedDcBufferSize)
{
_packedDcBufferSize = maxLossyDctDcSize * numLossyDctChans;
if (_packedDcBuffer != 0)
delete[] _packedDcBuffer;
_packedDcBuffer = new char[_packedDcBufferSize];
}

if (static_cast<size_t>(rleBufferSize) > _rleBufferSize)
if ( rleBufferSize > _rleBufferSize )
{
_rleBufferSize = rleBufferSize;
if (_rleBuffer != 0)
Expand All @@ -3091,7 +3099,7 @@ DwaCompressor::initializeBuffers (size_t &outBufferSize)
// all in one swoop (for each compression scheme).
//

int planarUncBufferSize[NUM_COMPRESSOR_SCHEMES];
Int64 planarUncBufferSize[NUM_COMPRESSOR_SCHEMES];
for (int i=0; i<NUM_COMPRESSOR_SCHEMES; ++i)
planarUncBufferSize[i] = 0;

Expand All @@ -3103,14 +3111,12 @@ DwaCompressor::initializeBuffers (size_t &outBufferSize)
break;

case RLE:
planarUncBufferSize[RLE] +=
numScanLines() * (_max[0] - _min[0] + 1) *
planarUncBufferSize[RLE] += pixelCount *
OPENEXR_IMF_NAMESPACE::pixelTypeSize (_channelData[chan].type);
break;

case UNKNOWN:
planarUncBufferSize[UNKNOWN] +=
numScanLines() * (_max[0] - _min[0] + 1) *
planarUncBufferSize[UNKNOWN] += pixelCount *
OPENEXR_IMF_NAMESPACE::pixelTypeSize (_channelData[chan].type);
break;

Expand All @@ -3127,17 +3133,23 @@ DwaCompressor::initializeBuffers (size_t &outBufferSize)

if (planarUncBufferSize[UNKNOWN] > 0)
{
planarUncBufferSize[UNKNOWN] =
compressBound ((uLongf)planarUncBufferSize[UNKNOWN]);
planarUncBufferSize[UNKNOWN] =
static_cast<Int64>( compressBound (planarUncBufferSize[UNKNOWN]) );
}

for (int i = 0; i < NUM_COMPRESSOR_SCHEMES; ++i)
{
if (static_cast<size_t>(planarUncBufferSize[i]) > _planarUncBufferSize[i])
if ( planarUncBufferSize[i] > _planarUncBufferSize[i])
{
_planarUncBufferSize[i] = planarUncBufferSize[i];
if (_planarUncBuffer[i] != 0)
delete[] _planarUncBuffer[i];

if (planarUncBufferSize[i] > std::numeric_limits<size_t>::max())
{
throw IEX_NAMESPACE::ArgExc("DWA buffers too large");
}

_planarUncBuffer[i] = new char[planarUncBufferSize[i]];
}
}
Expand Down
20 changes: 10 additions & 10 deletions OpenEXR/IlmImf/ImfDwaCompressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,16 @@ class DwaCompressor: public Compressor
std::vector<CscChannelSet> _cscSets;
std::vector<Classifier> _channelRules;

char *_packedAcBuffer;
size_t _packedAcBufferSize;
char *_packedDcBuffer;
size_t _packedDcBufferSize;
char *_rleBuffer;
size_t _rleBufferSize;
char *_outBuffer;
size_t _outBufferSize;
char *_planarUncBuffer[NUM_COMPRESSOR_SCHEMES];
size_t _planarUncBufferSize[NUM_COMPRESSOR_SCHEMES];
char* _packedAcBuffer;
Int64 _packedAcBufferSize;
char* _packedDcBuffer;
Int64 _packedDcBufferSize;
char* _rleBuffer;
Int64 _rleBufferSize;
char* _outBuffer;
Int64 _outBufferSize;
char* _planarUncBuffer[NUM_COMPRESSOR_SCHEMES];
Int64 _planarUncBufferSize[NUM_COMPRESSOR_SCHEMES];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it OK to change the memory layout of DwaCompressor for 32 bit systems between point releases? I assume it's OK, as the object isn't part of the API. I can imagine some horrific situation where a host application is linked against 2.2.4 but loads plugins linked against 2.2.5, and DwaCompressor object created by the 2.2.5 library gets passed to a 2.2.4 method.
(This should all be fine on systems where sizeof(size_t) == sizeof(Int64))


Zip *_zip;
float _dwaCompressionLevel;
Expand Down
Loading