From f4d3b6e8628c4148c636cb31f859b92f833d9a29 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 2 Jun 2023 14:36:03 +0000 Subject: [PATCH] Fix Stack-buffer-overflow READ in aiMaterial::AddBinaryProperty --- code/AssetLib/MDL/MDLMaterialLoader.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/AssetLib/MDL/MDLMaterialLoader.cpp b/code/AssetLib/MDL/MDLMaterialLoader.cpp index 799368264..aeefa5a04 100644 --- a/code/AssetLib/MDL/MDLMaterialLoader.cpp +++ b/code/AssetLib/MDL/MDLMaterialLoader.cpp @@ -493,12 +493,12 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7( aiString szFile; const size_t iLen = strlen((const char *)szCurrent); - size_t iLen2 = iLen + 1; - iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2; + size_t iLen2 = iLen > MAXLEN - 1 ? MAXLEN - 1: iLen; memcpy(szFile.data, (const char *)szCurrent, iLen2); + szFile.data[iLen2] = '\0'; szFile.length = static_cast(iLen2); - szCurrent += iLen2; + szCurrent += iLen2 + 1; // place this as diffuse texture pcMatOut->AddProperty(&szFile, AI_MATKEY_TEXTURE_DIFFUSE(0));