From 7d1fa60aa33b7c2609294e607a88d5ebcb635613 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 9 Dec 2025 23:28:44 +0100 Subject: [PATCH] Implement overflow check in Q3DLoader (#6417) * Implement overflow check in Q3DLoader --- code/AssetLib/Q3D/Q3DLoader.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/code/AssetLib/Q3D/Q3DLoader.cpp b/code/AssetLib/Q3D/Q3DLoader.cpp index 9c90ce153..ec63643d4 100644 --- a/code/AssetLib/Q3D/Q3DLoader.cpp +++ b/code/AssetLib/Q3D/Q3DLoader.cpp @@ -379,7 +379,12 @@ void Q3DImporter::InternReadFile(const std::string &pFile, light->mColorSpecular = light->mColorDiffuse; // We don't need the rest, but we need to know where this chunk ends. - unsigned int temp = (unsigned int)(stream.GetI4() * stream.GetI4()); + const auto t1 = stream.GetI4(); + const auto t2 = stream.GetI4(); + if (t1 < 0 || t2 < 0) { + throw DeadlyImportError("Quick3D: Overflow detected."); + } + const unsigned int temp = static_cast(t1*t2); // skip the background file name while (stream.GetI1())