Skip to content

Stack corruption in EbmlElement.cpp MakeRenderHead() #224

Description

@poikosoft

I got stack corruption in this function because the binary buffer was not large enough

64-bit coded size should be 12 octets ?

See the code:

filepos_t EbmlElement::MakeRenderHead(IOCallback & output, bool bKeepPosition)
{
//std::array<binary, 4 + 8> FinalHead; // Class D + 64 bits coded size
std::array<binary, 4 + 12> FinalHead; // Class D + 64 bits coded size (=12?)
std::size_t FinalHeadSize;

FinalHeadSize = EBML_ID_LENGTH((const EbmlId&)*this);
EbmlId(*this).Fill(FinalHead.data());

const int CodedSize = CodedSizeLength(Size, SizeLength, bSizeIsFinite);
CodedValueLength(Size, CodedSize, &FinalHead.at(FinalHeadSize));
FinalHeadSize += CodedSize;

output.writeFully(FinalHead.data(), FinalHeadSize);
if (!bKeepPosition) {
ElementPosition = output.getFilePointer() - FinalHeadSize;
SizePosition = ElementPosition + EBML_ID_LENGTH((const EbmlId&)*this);
}

return FinalHeadSize;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions