Merge pull request #15194 from unknownbrackets/psmf-validate

Psmf: Check for invalid stream/EP map entry counts
This commit is contained in:
Henrik Rydgård 2021-12-03 08:56:57 +01:00 committed by GitHub
commit e34f82627f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -304,6 +304,11 @@ public:
videoHeight_ = addr[13] * 16;
const u32 EP_MAP_STRIDE = 1 + 1 + 4 + 4;
if (psmf->headerOffset != 0 && !Memory::IsValidRange(psmf->headerOffset, psmf->EPMapOffset + EP_MAP_STRIDE * psmf->EPMapEntriesNum)) {
ERROR_LOG(ME, "Invalid PSMF EP map entry count: %d", psmf->EPMapEntriesNum);
psmf->EPMapEntriesNum = Memory::ValidSize(psmf->headerOffset + psmf->EPMapOffset, EP_MAP_STRIDE * psmf->EPMapEntriesNum) / EP_MAP_STRIDE;
}
psmf->EPMap.clear();
for (u32 i = 0; i < psmf->EPMapEntriesNum; i++) {
const u8 *const entryAddr = data + psmf->EPMapOffset + EP_MAP_STRIDE * i;
@ -378,6 +383,11 @@ Psmf::Psmf(const u8 *ptr, u32 data) {
currentStreamType = -1;
currentStreamChannel = -1;
if (data != 0 && !Memory::IsValidRange(data, 0x82 + numStreams * 16)) {
ERROR_LOG(ME, "Invalid PSMF stream count: %d", numStreams);
numStreams = Memory::ValidSize(data + 0x82, numStreams * 16) / 16;
}
for (int i = 0; i < numStreams; i++) {
PsmfStream *stream = 0;
const u8 *const currentStreamAddr = ptr + 0x82 + i * 16;