formats/bcpack: validate BC7 ctrl7 entries in Tables::parse #790
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/790"
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?
Imported from fxceless/victory-fork. Originally posted by AscilCH on 2026-11-25T07:35:43Z.
Summary
Validate BC7
ctrl7table entries inTables::parse()(crates/victory-formats/src/bcpack.rs):Tables::parse()previously loaded all 512ctrl7u16entries without checking their(mode, subsets, rot, part)fields.mode in {0, 1, 3}androt == 1causedbc7_precision()to swapprec[3] == 0intoprec[0], triggering au16 >> 16shift-overflow panic inbc7_pack()when writing p-bits. Other invalid combinations (mismatchedsubsets, non-zero rotation on modes without rotation, orpart >= 16on mode 0) silently produced malformed BC7 blocks.valid_bc7_ctrl()and reject invalid non-zeroctrl7entries inTables::parse().bcpack::tests::tables_parse_rejects_invalid_bc7_ctrl_codesverifying invalid control codes are rejected and valid ones (plus the built-in shipped tables) continue to parse cleanly.Verification
cargo test -p victory-formats --locked:26 passed; 0 failed; 4 ignored.cargo clippy -p victory-formats --all-targets --all-features --locked -- -D warnings: 0 warnings.cargo xtask policy:171 files ok.(AI-assisted; synthetic unit tests only, no game data.)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.