Add overfolow check for invalid data.

- closes https://github.com/assimp/assimp/issues/3422
pull/4809/head
Kim Kulling 2022-11-22 10:50:52 +01:00 committed by GitHub
parent b3daec65a0
commit 5689ac7869
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -404,8 +404,13 @@ void MDLImporter::InternReadFile_Quake1() {
this->CreateTextureARGB8_3DGS_MDL3(szCurrent + iNumImages * sizeof(float)); this->CreateTextureARGB8_3DGS_MDL3(szCurrent + iNumImages * sizeof(float));
} }
// go to the end of the skin section / the beginning of the next skin // go to the end of the skin section / the beginning of the next skin
szCurrent += pcHeader->skinheight * pcHeader->skinwidth + bool overflow = false;
sizeof(float) * iNumImages; if ((pcHeader->skinheight > INT_MAX / pcHeader->skinwidth) || (pcHeader->skinwidth > INT_MAX / pcHeader->skinheight)){
overflow = true;
}
if (!overflow) {
szCurrent += pcHeader->skinheight * pcHeader->skinwidth +sizeof(float) * iNumImages;
}
} }
} else { } else {
szCurrent += sizeof(uint32_t); szCurrent += sizeof(uint32_t);