Selaa lähdekoodia

Merge pull request #3350 from MalcolmTyrrell/fbxVersionCheck

FBX Version/Size Check
Kim Kulling 5 vuotta sitten
vanhempi
commit
aa6c35f683
1 muutettua tiedostoa jossa 14 lisäystä ja 3 poistoa
  1. 14 3
      code/AssetLib/FBX/FBXBinaryTokenizer.cpp

+ 14 - 3
code/AssetLib/FBX/FBXBinaryTokenizer.cpp

@@ -54,6 +54,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <assimp/Exceptional.h>
 #include <assimp/ByteSwapper.h>
 #include <assimp/DefaultLogger.hpp>
+#include <assimp/StringUtils.h>
 
 namespace Assimp {
 namespace FBX {
@@ -456,10 +457,20 @@ void TokenizeBinary(TokenList& output_tokens, const char* input, size_t length)
 	ASSIMP_LOG_DEBUG_F("FBX version: ", version);
 	const bool is64bits = version >= 7500;
     const char *end = input + length;
-    while (cursor < end ) {
-		if (!ReadScope(output_tokens, input, cursor, input + length, is64bits)) {
-            break;
+    try
+    {
+        while (cursor < end ) {
+		    if (!ReadScope(output_tokens, input, cursor, input + length, is64bits)) {
+                break;
+            }
+        }
+    }
+    catch (const DeadlyImportError& e)
+    {
+        if (!is64bits && (length > std::numeric_limits<std::uint32_t>::max())) {
+            throw DeadlyImportError("The FBX file is invalid. This may be because the content is too big for this older version (" + to_string(version) + ") of the FBX format. (" + e.what() + ")");
         }
+        throw;
     }
 }