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

Large dataWindow Offset test: for discussion #483

Merged
merged 1 commit into from
Aug 10, 2019
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
16 changes: 0 additions & 16 deletions OpenEXR/IlmImf/ImfHeader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,22 +802,6 @@ Header::sanityCheck (bool isTiled, bool isMultipartFile) const
"maximum height of " << maxImageHeight << "pixels.");
}

// make sure to avoid simple math overflow for large offsets
// we know we're at a positive width because of checks above
long long bigW = static_cast<long long>( w );
long long absOffY = std::abs ( dataWindow.min.y );
long long absOffX = std::abs ( dataWindow.min.x );
long long offX = static_cast<long long>( INT_MAX ) - absOffX;
long long offsetCount = absOffY * bigW;
long long bytesLeftPerLine = static_cast<long long>( INT_MAX ) / bigW;
if (bytesLeftPerLine < absOffY || offX < offsetCount)
{
THROW (IEX_NAMESPACE::ArgExc, "Data window [ (" << dataWindow.min.x
<< ", " << dataWindow.min.x << ") - (" << dataWindow.max.x
<< ", " << dataWindow.max.x
<< ") ] offset / size will overflow pointer calculations");
}

// chunk table must be smaller than the maximum image area
// (only reachable for unknown types or damaged files: will have thrown earlier
// for regular image types)
Expand Down
1 change: 1 addition & 0 deletions OpenEXR/IlmImfTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ add_executable(IlmImfTest
testWav.cpp
testXdr.cpp
testYca.cpp
testLargeDataWindowOffsets.cpp
)
target_compile_definitions(IlmImfTest PRIVATE ILM_IMF_TEST_IMAGEDIR="${CMAKE_CURRENT_SOURCE_DIR}/")
target_link_libraries(IlmImfTest OpenEXR::IlmImf)
Expand Down
1 change: 1 addition & 0 deletions OpenEXR/IlmImfTest/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ IlmImfTest_SOURCES = main.cpp tmpDir.h testAttributes.cpp testChannels.cpp \
testFutureProofing.cpp testFutureProofing.h \
compareDwa.cpp compareDwa.h \
testDwaCompressorSimd.cpp testDwaCompressorSimd.h \
testLargeDataWindowOffsets.cpp testLargeDataWindowOffsets.h \
testRle.cpp testRle.h \
bswap_32.h

Expand Down
2 changes: 2 additions & 0 deletions OpenEXR/IlmImfTest/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#include "testYca.h"
#include "testTiledYa.h"
#include "testIsComplete.h"
#include "testLargeDataWindowOffsets.h"
#include "testSharedFrameBuffer.h"
#include "testMultiView.h"
#include "testMultiPartApi.h"
Expand Down Expand Up @@ -155,6 +156,7 @@ main (int argc, char *argv[])
TEST (testHuf, "core");
TEST (testWav, "core");
TEST (testRgba, "basic");
TEST (testLargeDataWindowOffsets, "basic");
TEST (testSharedFrameBuffer, "basic");
TEST (testRgbaThreading, "basic");
TEST (testChannels, "basic");
Expand Down
Loading