Skip to content

Commit

Permalink
Merge pull request #452 from nyalldawson/permissive_align
Browse files Browse the repository at this point in the history
Relax bin chunk end alignment check in permissive mode
  • Loading branch information
syoyo authored Sep 6, 2023
2 parents fe6a182 + 4d119d7 commit 35735bb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tiny_gltf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 35735bb

Please sign in to comment.