Skip to content

Commit

Permalink
KaxBlockInternal: check EBML lace sizes against available buffer space
Browse files Browse the repository at this point in the history
  • Loading branch information
mbunkus committed Oct 20, 2015
1 parent 4934049 commit 0a2d3e3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
2015-10-20 Moritz Bunkus <moritz@bunkus.org>

* KaxInternalBlock::ReadData(): Fixed an invalid memory
access. When reading a block group or a simple block that uses
EBML lacing the frame sizes indicated in the lacing weren't
checked against the available number of bytes. If the indicated
frame size was bigger than the whole block's size the parser would
read beyond the end of the buffer resulting in a heap information
leak.

2015-10-17 Moritz Bunkus <moritz@bunkus.org>

* Released v1.4.3.
Expand Down
4 changes: 4 additions & 0 deletions src/KaxBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,8 @@ filepos_t KaxInternalBlock::ReadData(IOCallback & input, ScopeMode ReadFully)
case LACING_EBML:
SizeRead = LastBufferSize;
FrameSize = ReadCodedSizeValue(BufferStart + Mem.GetPosition(), SizeRead, SizeUnknown);
if (!FrameSize || (static_cast<uint32>(FrameSize + SizeRead) > LastBufferSize))
throw SafeReadIOCallback::EndOfStreamX(SizeRead);
SizeList[0] = FrameSize;
Mem.Skip(SizeRead);
LastBufferSize -= FrameSize + SizeRead;
Expand All @@ -537,6 +539,8 @@ filepos_t KaxInternalBlock::ReadData(IOCallback & input, ScopeMode ReadFully)
// get the size of the frame
SizeRead = LastBufferSize;
FrameSize += ReadCodedSizeSignedValue(BufferStart + Mem.GetPosition(), SizeRead, SizeUnknown);
if (!FrameSize || (static_cast<uint32>(FrameSize + SizeRead) > LastBufferSize))
throw SafeReadIOCallback::EndOfStreamX(SizeRead);
SizeList[Index] = FrameSize;
Mem.Skip(SizeRead);
LastBufferSize -= FrameSize + SizeRead;
Expand Down

0 comments on commit 0a2d3e3

Please sign in to comment.