From 5689ac7869c146c32f10752d55ae268fbfba5437 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 22 Nov 2022 10:50:52 +0100 Subject: [PATCH] Add overfolow check for invalid data. - closes https://github.com/assimp/assimp/issues/3422 --- code/AssetLib/MDL/MDLLoader.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/code/AssetLib/MDL/MDLLoader.cpp b/code/AssetLib/MDL/MDLLoader.cpp index c0a63709b..0ae25580a 100644 --- a/code/AssetLib/MDL/MDLLoader.cpp +++ b/code/AssetLib/MDL/MDLLoader.cpp @@ -404,8 +404,13 @@ void MDLImporter::InternReadFile_Quake1() { this->CreateTextureARGB8_3DGS_MDL3(szCurrent + iNumImages * sizeof(float)); } // go to the end of the skin section / the beginning of the next skin - szCurrent += pcHeader->skinheight * pcHeader->skinwidth + - sizeof(float) * iNumImages; + bool overflow = false; + 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 { szCurrent += sizeof(uint32_t);