1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 16:15:31 +00:00

Add some validation for bsa parsing

This should fix #5955
This commit is contained in:
jvoisin 2021-04-16 18:33:12 +02:00
parent e350d7d4ff
commit 47ced7dec4

View file

@ -168,6 +168,14 @@ void BSAFile::readHeader()
fs.setNameInfos(namesOffset, &mStringBuf);
fs.hash = hashes[i];
if (namesOffset >= mStringBuf.size()) {
fail("Archive contains names offset outside itself");
}
const void* end = std::memchr(fs.name(), '\0', mStringBuf.size()-namesOffset);
if (!end) {
fail("Archive contains non-zero terminated string");
}
endOfNameBuffer = std::max(endOfNameBuffer, namesOffset + std::strlen(fs.name())+1);
assert(endOfNameBuffer <= mStringBuf.size());