2
0
Эх сурвалжийг харах

Fix buffer overflow in MD5Parser::SkipSpacesAndLineEnd (#5921)

Co-authored-by: Kim Kulling <[email protected]>
tyler92 8 сар өмнө
parent
commit
ecc8a1c869

+ 9 - 5
code/AssetLib/MD5/MD5Parser.cpp

@@ -115,14 +115,18 @@ void MD5Parser::ParseHeader() {
         ReportError("MD5 version tag is unknown (10 is expected)");
     }
     SkipLine();
-    if (buffer == bufferEnd) {
-        return;
-    }
 
     // print the command line options to the console
-    // FIX: can break the log length limit, so we need to be careful
     char *sz = buffer;
-    while (!IsLineEnd(*buffer++));
+    while (buffer < bufferEnd) {
+        if (IsLineEnd(*buffer++)) {
+            break;
+        }
+    }
+
+    if (buffer == bufferEnd) {
+        return;
+    }
     
     ASSIMP_LOG_INFO(std::string(sz, std::min((uintptr_t)MAX_LOG_MESSAGE_LENGTH, (uintptr_t)(buffer - sz))));
     SkipSpacesAndLineEnd();