-
Notifications
You must be signed in to change notification settings - Fork 616
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
reduce size limit for scanline files; prevent large chunkoffset allocations #824
Changes from 3 commits
dfa52f4
c72485f
997d42c
81a54c3
43bcd29
03363f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -741,7 +741,9 @@ MultiPartInputFile::Data::getPart(int partNumber) | |
return parts[partNumber]; | ||
} | ||
|
||
|
||
namespace{ | ||
static const int gLargeChunkTableSize = 1024*1024; | ||
} | ||
|
||
void | ||
MultiPartInputFile::Data::readChunkOffsetTables(bool reconstructChunkOffsetTable) | ||
|
@@ -751,8 +753,26 @@ MultiPartInputFile::Data::readChunkOffsetTables(bool reconstructChunkOffsetTable | |
for (size_t i = 0; i < parts.size(); i++) | ||
{ | ||
int chunkOffsetTableSize = getChunkOffsetTableSize(parts[i]->header); | ||
|
||
// | ||
// avoid allocating excessive memory. | ||
// If the chunktablesize claims to be large, | ||
// check the file is big enough to contain the file before allocating memory | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean "file is big enough to contain the file"? And is the trick here that the read with throw an exception if the size is off? If so, it would be good to state that's the expectation. Same comment in ImfScanLineInputFile below, too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catches: Dumb typing errors. It should make more sense now |
||
// | ||
if(chunkOffsetTableSize > gLargeChunkTableSize) | ||
{ | ||
Int64 pos = is->tellg(); | ||
is->seekg(pos + (chunkOffsetTableSize-1)*sizeof(Int64)); | ||
Int64 temp; | ||
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (*is, temp); | ||
is->seekg(pos); | ||
|
||
} | ||
|
||
parts[i]->chunkOffsets.resize(chunkOffsetTableSize); | ||
|
||
|
||
|
||
for (int j = 0; j < chunkOffsetTableSize; j++) | ||
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (*is, parts[i]->chunkOffsets[j]); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is declared in ImfCompressor.h, does it need to be declared here, too?