From 4d119d72683ea757ccd9d9d8157c38757e31bf34 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Wed, 6 Sep 2023 17:35:25 +1000 Subject: [PATCH] Relax bin chunk end alignment check in permissive mode --- tiny_gltf.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tiny_gltf.h b/tiny_gltf.h index 2c5b98c..b68890b 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -6733,10 +6733,17 @@ bool TinyGLTF::LoadBinaryFromMemory(Model *model, std::string *err, } if ((chunk1_length % 4) != 0) { - if (err) { - (*err) = "BIN Chunk end does not aligned to a 4-byte boundary."; + if (strictness_==ParseStrictness::Permissive) { + if (warn) { + (*warn) += "BIN Chunk end is not aligned to a 4-byte boundary.\n"; + } + } + else { + if (err) { + (*err) = "BIN Chunk end is not aligned to a 4-byte boundary."; + } + return false; } - return false; } if (uint64_t(chunk1_length) + header_and_json_size > uint64_t(length)) {