mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:25:52 +01:00
[PR #1812] [MERGED] tools: harden bcpack_tables_bptc.py section validation, bounds and file cache #1825
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#1825
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/1812
Author: @kirigayakazima
Created: 11/25/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142
Base:
main← Head:fix/bcpack-bptc-safety📝 Commits (1)
81e34a5tools: harden bcpack_tables_bptc.py section validation, bounds and file cache📊 Changes
2 files changed (+167 additions, -58 deletions)
View changed files
📝
tests/test_bcpack_tables_bptc.py(+85 -0)📝
tools/bcpack_tables_bptc.py(+82 -58)📄 Description
Claimed in the coordination issue as: BCPACK-BPTC-SECTION-AND-VALIDATION-SAFETY (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7162308818)
What and why
_load_json_file()intools/bcpack_tables_bptc.pyfor both_read_history_section()andload_bc_history(), keying_FILE_CACHEbyos.path.realpathand(st_mtime_ns, st_size, st_dev, st_ino)so same-size, same-mtime atomic file replacements invalidate cleanly, and translatingRecursionErrortoValueError.{"bc6h": []},{"bc7": "bad"}) withValueErrorin_read_history_section()instead of failing later withAttributeError.list/tuple) inload_bc6h()(endpointHistory,indexHistory,endpointConfirmedBits,indexConfirmedBits) and inload_bc7()(historyEndpointLow2Fits,historyEndpointLastResort) so scalar rows raiseValueErrorinstead ofTypeError.ep_cb[k][field](0 <= cb <= 8) before computing8 - max(depth, cb)inhistoryEndpointLow2Fits(avoiding negative shift counts), and validate all indices inhistoryEndpointLastResort.tests/test_bcpack_tables_bptc.py.Tested
python -I tests/test_bcpack_tables_bptc.py -v->Ran 27 tests in 0.077s,OK(verified in a detachedupstream/mainworktree that all six new tests fail before the fix:FAILED (failures=8, errors=11)).test_bcpack.py,test_bcpack_history_calib.py,test_bcpack_native.py(skipped=12),test_bcpack_tables.py, andtest_bcpack_tool.py-> exit0.python -I tests/test_ci_registration.py->Ran 16 tests in 4.487s,OK.python -I tests/test_text_write_line_endings.py->Ran 3 tests in 12.675s,OK.python -I scripts/check_no_game_data.py tools/bcpack_tables_bptc.py tests/test_bcpack_tables_bptc.py-> exit0.python -I -m compileall -q tools/bcpack_tables_bptc.py tests/test_bcpack_tables_bptc.pyandgit diff --check-> clean.GPUs tested: n/a (CPU/stdlib Python tests on Windows 11 x64)
AI-assisted: yes
Checklist
needs rebase).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.