formats/xma: handle zero-frame continuation/empty packets in next_frame #627
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!627
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-627"
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?
@AscilCH on GitHub · 2026-11-25 03:26 UTC · original
AscilCH:fix/formats-xma-next-frame-zero-frame-packets→main· +80 −5 · 1 files · 1 commits · openProblem
Two bugs in
xma::next_frame(crates/victory-formats/src/xma.rs):frames == 0continuation packet: if a frame started in packetindexand finished inside a subsequent packetend_pktwhose header hasframes == 0(tail bits followed by0xFFpadding), neitherend.is_multiple_of(PACKET_BITS)norend / PACKET_BITS == indexheld.next_framereturnedSome(end)inside0xFFpadding, causing the nextread_frameto see length0x7fffand silently truncate the rest of the audio stream.frames == 0packet (first_frame_bit == 0x7fff): in XMA2, packets starting no frames setfirst_frame_bit = 0x7fff(32767 > PACKET_BITS - HEADER_BITS).next_frameunconditionally computednext * PACKET_BITS + HEADER_BITS + header.first_frame_bit, jumping ~2 packets forward right into another packet's header and bypassing that packet'sskipcount.Fix
end / PACKET_BITS != index && packet(data, end_pkt)?.frames == 0in addition to packet-boundary and intra-packet last-frame cases.skipchain across anyframes == 0packets until finding a packet withframes > 0, checkingHEADER_BITS + first_frame_bit < PACKET_BITS(and on the starting packet as well) with checked arithmetic.next_frame_handles_zero_frame_continuation_and_empty_packetscovering continuation packets, empty packets withskip, and invalidfirst_frame_bit.Verification
cargo test -p victory-formats --locked xma: 6 passed, 0 failed, 2 ignored (external dumps)cargo xtask policy: 169 files okcargo clippy -p victory-formats --all-targets --locked -- -D warnings: clean(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.