Browse Source

MDL: Fix read past end of buffer with malformed input

Turo Lamminen 10 years ago
parent
commit
4cc716a0f5
1 changed files with 3 additions and 0 deletions
  1. 3 0
      code/MDLLoader.cpp

+ 3 - 0
code/MDLLoader.cpp

@@ -355,6 +355,9 @@ void MDLImporter::InternReadFile_Quake1( )
     for (unsigned int i = 0; i < (unsigned int)pcHeader->num_skins;++i)
     {
         union{BE_NCONST MDL::Skin* pcSkin;BE_NCONST MDL::GroupSkin* pcGroupSkin;};
+        if (szCurrent + sizeof(MDL::Skin) > this->mBuffer + this->iFileSize) {
+            throw DeadlyImportError("[Quake 1 MDL] Unexpected EOF");
+        }
         pcSkin = (BE_NCONST MDL::Skin*)szCurrent;
 
         AI_SWAP4( pcSkin->group );