fix(b3dfile): cap chunk-stack depth + reject negative chunk size on malformed .b3d#565
Merged
Merged
Conversation
…alformed .b3d Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
What
Two additive soft-fail guards in
b3dReadChunk$(src/Modules/b3dfile.bb) hardening the.b3dmesh chunk reader against malformed/hostile input:If b3d_tos+1 > 100 Then Return ""before theb3d_tospush.b3d_stackisDim b3d_stack(100)(valid0..100); a file nested deeper than the stack capacity would otherwise OOB-writeb3d_stack.If sz < 0 Then Return ""beforeszis stored as a seek target (FilePos + sz), preventing a backward/infinite mis-seek.Both fail by returning an empty tag (matches no chunk reader) without advancing
b3d_tos, so neither path can OOB-write or corrupt parser state. Valid.b3dfiles are unaffected.Why
Untrusted-input parse-path hardening per the project's soft-fail / bounds-check doctrine (CLAUDE.md).
b3dfile.bbis Tools-shared (RC Terrain / RC Tree editors).Verification
sz = 0allowed,sz < 0rejected), no new OOB/underflow.compile.batclean (exit 0); bothRC Terrain EditorandRC Tree Editorbuild.b3dExitChunkunderflow is out of scope (tracked separately); the read-side helpers have no in-repo callers today, so this is risk-free defensive hardening.Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com