formats/xma: handle zero-frame continuation/empty packets in next_frame #627
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from fxceless/victory-fork. Originally posted by AscilCH on 2026-11-25T03:26:11Z.
Problem
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.