fix:add a protection to check memory overflow.

This commit is contained in:
xiaoyifang 2022-01-09 18:09:53 +08:00
parent 6318366a10
commit c3db39499b

6
mdx.cc
View file

@ -165,6 +165,12 @@ public:
const char * indexEntryPtr = chunks.getBlock( links[ 0 ].articleOffset, chunk );
memcpy( &indexEntry, indexEntryPtr, sizeof( indexEntry ) );
//corrupted file or broken entry.
if (indexEntry.decompressedBlockSize < indexEntry.recordOffset + indexEntry.recordSize)
{
return false;
}
ScopedMemMap compressed( mddFile, indexEntry.compressedBlockPos, indexEntry.compressedBlockSize );
if ( !compressed.startAddress() )
{