Repository navigation
io: validate vertex, texture, and normal index bounds in obj decoder (fixes #1194) - #1243
Open
jdymitarai wants to merge 1 commit into
Open
jdymitarai wants to merge 1 commit into
jdymitarai wants to merge 1 commit into
Conversation
jdymitarai
force-pushed
the
fix-obj-decoder-face-index-bounds-1194
branch
from
October 4, 2026 20:51
37d2ee6 to
c32790b
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root Cause
In
ObjDecoder, face corner indices were parsed without checking whether referenced vertex, texture, or normal indices exceeded the counts of defined attributes or were negative beyond the start offset. Out-of-bounds indices were stored directly into attribute point mappings, causing heap buffer overflows during attribute deduplication (PointAttribute::DeduplicateFormattedValues). Furthermore, malformed trailing corner indices on quads/polygons (such as index 0 or invalid attribute declarations) prematurely broke parsing without verifying genuine end-of-line, leaving uninitialized faces and points.Fix
ObjDecoder::ParseFace, check genuine line termination (\n,\r,#, or EOF) before breaking on trailing corners so malformed polygon indices cannot bypass parsing, and validate all corner indices fall within valid bounds for defined attributes before triangulation and mapping, returningStatus::DRACO_ERROR("Face index out of range") if any index is out of bounds.ObjDecoder::MapPointToVertexIndices, add defensive bounds validation rejecting invalid attribute indices (including 0 position indices).Verification
ObjDecoderTest.RejectOutOfRangeIndicescovering positive and negative out-of-range position, texture, and normal indices for mesh and point cloud decoding, quads/n-gons with invalid 4th corner indices, and malformed corner 0 declarations.draco_tests), passing 189/189 tests cleanly without regressions.