From 6b9f9afd7abf47aabb847bd52324e60b8458416f Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sun, 1 Feb 2015 00:02:12 +0200 Subject: [PATCH 1/3] Fix infinite loop in STL loader If next character was not part of valid token and not whitespace we would end up spinning in the loop indefinitely. Fix by using do..while loop which always skips at least one character. Fixes testcase hangs/73b42cd3b6d05e2ddb5c0fe5888459bc --- code/STLLoader.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/STLLoader.cpp b/code/STLLoader.cpp index 6fedcd34a..a31df8a1e 100644 --- a/code/STLLoader.cpp +++ b/code/STLLoader.cpp @@ -326,8 +326,10 @@ void STLImporter::LoadASCIIFile() break; } // else skip the whole identifier - else while (!::IsSpaceOrNewLine(*sz)) { - ++sz; + else { + do { + ++sz; + } while (!::IsSpaceOrNewLine(*sz)); } } From fe89773c6fb10bd1a06f692ba9af473f2f625b31 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sun, 1 Feb 2015 00:22:32 +0200 Subject: [PATCH 2/3] Fix infinite loop in PLY parser Fixes testcase hangs/9ab979ab256c70aaec9b651f32f051e9 --- code/PlyParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/PlyParser.cpp b/code/PlyParser.cpp index 6687ca9ed..7c2165983 100644 --- a/code/PlyParser.cpp +++ b/code/PlyParser.cpp @@ -436,7 +436,7 @@ bool PLY::DOM::ParseHeader (const char* pCur,const char** pCurOut,bool isBinary) *pCurOut = pCur; // parse all elements - while (true) + while ((*pCur) != '\0') { // skip all comments PLY::DOM::SkipComments(pCur,&pCur); From b93bd167ed72e7a8d9ed6329579ac7755c0620e2 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sun, 1 Feb 2015 00:35:00 +0200 Subject: [PATCH 3/3] Fix infinite loop in STL loader error path It appears that this was never tested since hitting it caused an infinite loop. Fixes testcase hangs/c2eb1fa3e74c6ffe0cebcb1672b03140 --- code/STLLoader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/STLLoader.cpp b/code/STLLoader.cpp index a31df8a1e..987de89d0 100644 --- a/code/STLLoader.cpp +++ b/code/STLLoader.cpp @@ -308,6 +308,7 @@ void STLImporter::LoadASCIIFile() { if (3 == curVertex) { DefaultLogger::get()->error("STL: a facet with more than 3 vertices has been found"); + ++sz; } else {