Formats: add cargo-fuzz targets for the BCPack and XMA decoders #3324
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3324
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3324"
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?
@gabrielvbraga on GitHub · 2026-11-26 18:07 UTC · original
gabrielvbraga:fuzz-formats→main· +252 −0 · 7 files · 2 commits · openCloses #3311.
Adds a standalone
fuzz/crate with three cargo-fuzz targets forvictory-formats:bcpack_tables:Tables::parseon raw bytes and on the shipped tables with fuzzer-chosen bytes overwritten, thendecodewith any tables that still parse.bcpack_decode:decodefor every supported BC format (1, 3, 4, 5, 6, 7) with the shipped tables.xma_frames:packet,read_frame(packet walk and arbitrary bit offsets) andDecoder::decode/flush.The crate has its own
[workspace], so the main build, tests, CI andrust-toolchain.tomlare unaffected; nightly is only needed to run it. No game data, corpora or binaries are committed. New dependency:libfuzzer-sys(MIT/Apache-2.0, libFuzzer under Apache-2.0 with LLVM exception), used only in this crate.fuzz/README.mdexplains how to run it and turn a crash into a regression test.Findings
bcpack_tablesindependently found the BC7 rotation shift overflow (bcpack.rs:866,attempt to shift right with overflow) within a few minutes. It is the bug #3111 fixes; with #3111 applied, the input no longer panics and the target ran 30 min clean (details in #3111).Tested
rustc 1.102.0-nightly (6c709eb42 2026-11-25)cargo test -p victory-formats: 46 passed, 0 failed, 5 ignoredcargo +nightly fuzz build --debug-assertions: OK--debug-assertions:bcpack_decodeonmain(63bcca4): 14,055,889 execs, no crashbcpack_tablesonmain+ #3111: 1,532,884 execs, no crashxma_framesonmain(63bcca4): 3,646,222 execs, no crash (-max_len=16385)Not tested
texture.rshas no target yet.@Dukestar69 on GitHub · 2026-11-26 18:29 UTC · original
Quick correction to the clippy line above:
cargo check --manifest-path fuzz/Cargo.toml --all-targetsandcargo xtask policy(198 files ok) both passed, whilecargo clippy --manifest-path fuzz/Cargo.toml --all-targets -- -D warningson Rust 1.98 flagged one minor pedantic/nursery-free lint infuzz/fuzz_targets/bcpack_tables.rs:16:clippy::chunks_exact_to_as_chunks:data.chunks_exact(4)->data.as_chunks::<4>().0.The targets themselves are unaffected (
fuzz/is a separate workspace).Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@Dukestar69 on GitHub · 2026-11-26 18:29 UTC · original · approved these changes
LGTM — verified on Windows against
origin/main(63bcca4).[workspace]infuzz/Cargo.tomlkeeps the main workspace/CI unaffected while adding clean, boundedcargo-fuzztargets forbcpack::Tables::parse,bcpack::decode, andxmapacket/frame decoding.cargo check --manifest-path fuzz/Cargo.toml --all-targets: clean.cargo clippy --manifest-path fuzz/Cargo.toml --all-targets -- -D warnings: clean.cargo xtask policy: 198 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@gabrielvbraga on GitHub · 2026-11-26 18:38 UTC · original
Thanks for testing and for the catch. Fixed in the latest commit:
bcpack_tablesnow usesdata.as_chunks::<4>().0.cargo clippy --manifest-path fuzz/Cargo.toml --all-targets -- -D warningsis clean on both 1.98.1 and nightly, andcargo +nightly fuzz build --debug-assertionsstill builds.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.