Skip to content

Fix integer overflow in accessor validation#293

Open
zeux wants to merge 1 commit into
jkuhlmann:masterfrom
zeux:fix-intovf
Open

Fix integer overflow in accessor validation#293
zeux wants to merge 1 commit into
jkuhlmann:masterfrom
zeux:fix-intovf

Conversation

@zeux

@zeux zeux commented May 4, 2026

Copy link
Copy Markdown
Contributor

For dense and sparse accessors, we now avoid integer overflow by making sure offset+size*count fits into size_t and if it doesn't, clamping to SIZE_MAX. SIZE_MAX should fail the validation check (even if it doesn't, it's impossible to allocate an array with size SIZE_MAX so the code becomes transitively memory safe).

Also fix count=0 restrictions that could lead to benign underflow.

Fixes #287

For dense and sparse accessors, we now avoid integer overflow by
making sure offset+size*count fits into size_t and if it doesn't,
clamping to SIZE_MAX. SIZE_MAX should fail the validation check (even if
it doesn't, it's impossible to allocate an array with size SIZE_MAX so
the code becomes transitively memory safe).

Also fix count=0 restrictions that could lead to benign underflow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integer Overflow in cgltf_validate() Sparse Accessor Validation Leads to Heap Buffer Overflow on read

1 participant