mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:50:52 +01:00
[PR #1512] skinned_glb: validate GLB chunks, accessor bounds, skeleton cycles, skin streams, and indices (SKINNED-GLB-VALIDATION-HARDENING) #1542
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1542
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1512
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/skinned-glb-hardening📝 Commits (1)
ced0d9eskinned_glb: validate GLB chunks, accessor bounds, skeleton cycles, skin streams, and indices📊 Changes
2 files changed (+447 additions, -46 deletions)
View changed files
📝
tests/test_skinned_glb.py(+277 -0)📝
tools/skinned_glb.py(+170 -46)📄 Description
Claimed in the coordination issue as: SKINNED-GLB-VALIDATION-HARDENING (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7151315288)
What and why
Hardens
tools/skinned_glb.pyagainst malformed GLB containers, out-of-bounds accessors, cyclic skeletons, short skin headers,bool-as-intbugs, and invalid glTF primitive indices/attributes:read_glb):total_lengthagainst file size,CHUNK_JSON/CHUNK_BINchunk types, and JSON/BIN chunk bounds (plusRecursionErroron malformed JSON), raisingSkinErrorinstead of accepting truncated or non-BIN chunks.accessor_bytes):boolindices, counts, strides, and byte offsets, validatesbufferView.byteLengthagainstbin_data, and ensures the accessor span does not extend past itsbufferView._finite_matrix,_bone_name_map,JointSet,PaletteResolver,own_parent_name):_finite_matrixchecksisinstance(m, (list, tuple))and rejectsboolelements instead of raising rawTypeErrorwhenbind_matrixisNone.JointSet.__init__rejects non-dict bone entries, ignoresboolparentvalues, and rejects self-parenting and multi-bone parent cycles withSkinErrorinstead of producing cyclic glTF node graphs;JointSet.addrejectsboolparent.PaletteResolverandown_parent_nameguard against non-dict/non-listdrawable/skeleton/stringsfields andboolparent indices.read_skin_streams,normalise_weights):base + 92 > len(blob)) withSkinErrorbefore reading the 23-word section header (previously raised uncaughtstruct.erroron CLI).boolgeometry/model/vertex_bufferindices,boolbone_palette/vertex_count/gfx_off/mesh_blob.sectionsentries, non-stringbuffer_filesentries, andboolarguments innormalise_weights(and removes a duplicate zeroing line in the NumPy path).build_skinned_glb,_validate_indices):NORMAL,TANGENT,TEXCOORD_*,COLOR_0) matchesstreams["count"], not justPOSITION.SCALARwith integercomponentType(UNSIGNED_BYTE/UNSIGNED_SHORT/UNSIGNED_INT), positive multiple-of-3 count, and all indices< vertex_count.OverflowErrorwhen packinginverseBindMatricesand converts it toSkinError.main):sys.path.insert.Tested
python3 -I tests/test_skinned_glb.py -v(stdlib path): 38/38 OK (30 existing + 8 new tests inValidationHardeningTests).python3 tests/test_skinned_glb.py(with NumPy installed): 38/38 OK.main:tools/skinned_glb.py: all 8 new tests inValidationHardeningTestsfail (FAILED (failures=17, errors=4)).python3 -I tests/test_text_write_line_endings.py: 3/3 OK.python3 -I scripts/check_no_game_data.py tools/skinned_glb.py tests/test_skinned_glb.py: clean.python3 -m compileall -q tools/skinned_glb.py tests/test_skinned_glb.py: clean.GPUs tested: n/a (Python tool, synthetic unit tests only, no GPU or game data)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a — no translator rule changes)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.