Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix integer overflow during GLB chunk length validation #240

Merged
merged 1 commit into from
Dec 6, 2023
Merged

Fix integer overflow during GLB chunk length validation #240

merged 1 commit into from
Dec 6, 2023

Conversation

zeux
Copy link
Contributor

@zeux zeux commented Dec 2, 2023

Validation of input lengths must be performed by comparing the length with the remainder of the input data; the latter can be safely computed because we validate the remainder after every step incrementally.

Before this change, length validation was doing math in 32-bit space and could thus overflow, exposing data after the input buffer to the parser.

This was always a problem on 32-bit systems; it only became a problem on 64-bit systems after the VLA change, as before it GlbHeaderSize et al had type cgltf_size.

Found by fuzzing. Regression (on 64-bit systems) since #238.

Validation of input lengths must be performed by comparing the length
with the remainder of the input data; the latter can be safely computed
because we validate the remainder after every step incrementally.

Before this change, length validation was doing math in 32-bit space and
could thus overflow, exposing data after the input buffer to the parser.

This was always a problem on 32-bit systems; it only became a problem on
64-bit systems after the VLA change, as before it GlbHeaderSize et al
had type cgltf_size.
zeux added a commit to zeux/meshoptimizer that referenced this pull request Dec 3, 2023
This is a regression from the recent update so we need to apply the
patch from jkuhlmann/cgltf#240
@jkuhlmann jkuhlmann merged commit 8731d31 into jkuhlmann:master Dec 6, 2023
3 checks passed
@zeux zeux deleted the fix-glb-overflow branch December 6, 2023 21:00
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.

2 participants