Skip to content

Commit

Permalink
limit the buffer_size
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamedchebbii committed Dec 13, 2022
1 parent 09b28cb commit 1d8e204
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/riffvideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,13 +506,18 @@ void RiffVideo::printStructure(std::ostream& out, PrintStructureOption option, s
<< std::endl;
}

const uint64_t bufMaxSize = 200;
io_->seek(0, BasicIo::beg); // rewind
while (!io_->eof() && (uint64_t)io_->tell() < filesize) {
uint64_t offset = (uint64_t)io_->tell();
byte size_buff[RIFF_TAG_SIZE];
io_->read(chunkId.data(), RIFF_TAG_SIZE);
io_->read(size_buff, RIFF_TAG_SIZE);
uint32_t size = Exiv2::getULong(size_buff, littleEndian);
if (size > bufMaxSize) {
io_->seek(size, BasicIo::cur);
continue;
}
DataBuf payload(offset ? size : RIFF_TAG_SIZE); // header is different from chunks
io_->read(payload.data(), payload.size());

Expand Down

0 comments on commit 1d8e204

Please sign in to comment.