bary_fallback_gs: validate input locations/index schema/shader names, accept UTF-8 BOM, and publish atomically (BARY-FALLBACK-GS-VALIDATION-ATOMIC) #1440
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!1440
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/bary-fallback-gs-validation-atomic"
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 successfully merged and closed
Item ID:
BARY-FALLBACK-GS-VALIDATION-ATOMICAI-assisted: yes
Summary
Fixes five input-validation and file-publishing bugs in
tools/bary_fallback_gs.py:locationsings_spvasm():int(n)previously accepted negative integers (-1, emitting illegal SPIR-V identifier%in-1andLocation -1), booleans (True/False), and floats (1.5), while string digits ("5","1","3") are expected by callers._parse_location()rejects booleans, floats, and negative values withValueErrorwhile preserving non-negativeintand digit-string inputs.index.jsonshader names:_helpers_for_index()joinedspirv_dirwithname + ".bary_gs..."without validatingname, allowing../escape,/abs, orsub/pskeys to write outsidespirv_dir._validate_shader_name()rejects empty names,.,.., and any name containing/or\(or whereos.path.basename(name) != name) withValueError.index.jsonfields intoValueErrorinstead of uncaught tracebacks:capabilities(e.g.null,[1]), truthy non-dict or missing-locationbary_fallback_input, and non-listinputs(e.g.null,"01") previously escapedmain()'sexcept (OSError, ValueError, RuntimeError)asTypeError/KeyErrortracebacks or iterated characters of a string.index.json:index.jsonwithencoding="utf-8-sig"(consistent withtools/hashdict.pyandtools/bcpack_tables_bptc.py).write_for_index():.spvasmfiles viatempfile.NamedTemporaryFile(mode="w", encoding="utf-8", newline="\n", ...)+file_mode.published_mode+os.replacewith cleanup on failure so existing helper files are never truncated on write errors.Verification (macOS Apple M5, arm64, Python 3.14; no game files)
python3 -m compileall -q make_game.py tools tests— OKpython3 -I scripts/check_no_game_data.py tools/bary_fallback_gs.py tests/test_bary_fallback_gs.py— OKpython3 -I tests/test_bary_fallback_gs.py -v— 34 tests OK (1 skipped: SPIRV-Tools not installed on host; 5 new regression tests)python3 -I tests/test_text_write_line_endings.py— 3/3 OKpython3 -I tests/test_ci_registration.py— 16/16 OKtests/test_bary_fallback_gs.pyagainst unpatchedupstream/mainb4b7756e8):Ran 34 tests — FAILED (failures=10, errors=8, skipped=1)— catches negative/bool/float locations, path-traversal shader names, uncaughtTypeError/KeyErroron malformed index fields, UTF-8 BOM rejection, and non-atomicwrite_for_index.Red/green: the PR's tests fail on main 4938673 and pass on head e726995fa973 (Linux, Python 3.13.18).
Targeted batch of 11 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13.
AI-assisted (Claude Code, Claude Opus 5.5)