Skip to content

Commit

Permalink
extern: Update cgltf to include the GLB parsing fix
Browse files Browse the repository at this point in the history
This is a regression from the recent update so we need to apply the
patch from jkuhlmann/cgltf#240
  • Loading branch information
zeux committed Dec 3, 2023
1 parent 91433d1 commit f7982fc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions extern/cgltf.h
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ cgltf_result cgltf_parse(const cgltf_options* options, const void* data, cgltf_s
// JSON chunk: length
uint32_t json_length;
memcpy(&json_length, json_chunk, 4);
if (GlbHeaderSize + GlbChunkHeaderSize + json_length > size)
if (json_length > size - GlbHeaderSize - GlbChunkHeaderSize)
{
return cgltf_result_data_too_short;
}
Expand All @@ -1164,15 +1164,15 @@ cgltf_result cgltf_parse(const cgltf_options* options, const void* data, cgltf_s
const void* bin = NULL;
cgltf_size bin_size = 0;

if (GlbHeaderSize + GlbChunkHeaderSize + json_length + GlbChunkHeaderSize <= size)
if (GlbChunkHeaderSize <= size - GlbHeaderSize - GlbChunkHeaderSize - json_length)
{
// We can read another chunk
const uint8_t* bin_chunk = json_chunk + json_length;

// Bin chunk: length
uint32_t bin_length;
memcpy(&bin_length, bin_chunk, 4);
if (GlbHeaderSize + GlbChunkHeaderSize + json_length + GlbChunkHeaderSize + bin_length > size)
if (bin_length > size - GlbHeaderSize - GlbChunkHeaderSize - json_length - GlbChunkHeaderSize)
{
return cgltf_result_data_too_short;
}
Expand Down

0 comments on commit f7982fc

Please sign in to comment.