mirror of
https://github.com/OpenMW/openmw.git
synced 2025-12-12 19:13:07 +00:00
Merge branch 'fix_bsa' into 'master'
Add some validation for bsa parsing Closes #5955 See merge request OpenMW/openmw!750
This commit is contained in:
commit
d3c865d909
1 changed files with 8 additions and 0 deletions
|
|
@ -168,6 +168,14 @@ void BSAFile::readHeader()
|
||||||
fs.setNameInfos(namesOffset, &mStringBuf);
|
fs.setNameInfos(namesOffset, &mStringBuf);
|
||||||
fs.hash = hashes[i];
|
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);
|
endOfNameBuffer = std::max(endOfNameBuffer, namesOffset + std::strlen(fs.name())+1);
|
||||||
assert(endOfNameBuffer <= mStringBuf.size());
|
assert(endOfNameBuffer <= mStringBuf.size());
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue