From b39446b7bbd357f9d78c6e759d3af1b16cba540f Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Mon, 10 Aug 2015 15:48:26 +0300 Subject: [PATCH] Avoid reading past EOF when encountering a malformed STL file Since IsSpaceOrNewLine returns true on '\0' we might try to read past end of buffer on line 310. Add explicit check to avoid this. --- code/STLLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/STLLoader.cpp b/code/STLLoader.cpp index ad445efdb..de70dd7a3 100644 --- a/code/STLLoader.cpp +++ b/code/STLLoader.cpp @@ -279,7 +279,7 @@ void STLImporter::LoadASCIIFile() break; } // facet normal -0.13 -0.13 -0.98 - if (!strncmp(sz,"facet",5) && IsSpaceOrNewLine(*(sz+5))) { + if (!strncmp(sz,"facet",5) && IsSpaceOrNewLine(*(sz+5)) && *(sz + 5) != '\0') { if (3 != curVertex) { DefaultLogger::get()->warn("STL: A new facet begins but the old is not yet complete");