MD3: Check file is big enough to contain all the advertised surfaces

This commit is contained in:
Turo Lamminen
2016-03-13 00:54:23 +02:00
parent da0b180901
commit 555f533777

View File

@@ -407,6 +407,14 @@ void MD3Importer::ValidateHeaderOffsets()
throw DeadlyImportError("Invalid MD3 header: some offsets are outside the file");
}
if (pcHeader->NUM_SURFACES > AI_MAX_ALLOC(MD3::Surface)) {
throw DeadlyImportError("Invalid MD3 header: too many surfaces, would overflow");
}
if (pcHeader->OFS_SURFACES + pcHeader->NUM_SURFACES * sizeof(MD3::Surface) >= fileSize) {
throw DeadlyImportError("Invalid MD3 header: some surfaces are outside the file");
}
if (pcHeader->NUM_FRAMES <= configFrameID )
throw DeadlyImportError("The requested frame is not existing the file");
}