Commit Graph

1 Commits

Author SHA1 Message Date
Kevin Bortis
83433faaf7 Fix v1 image verification and add aaruf_verify_image tests
V1 images stored cmpCrc64 over the full LZMA payload including the
5-byte properties prefix, but verify.c unconditionally skipped the
prefix before computing the CRC. This caused aaruf_verify_image() to
report AARUF_ERROR_INVALID_BLOCK_CRC on every valid v1 image.

The fix makes the LZMA properties skip conditional on v2+ images:
- V1: CRC computed over full cmpLength (properties included), then byte-swapped
- V2+: CRC computed over cmpLength minus 5 (properties excluded), no byte-swap

Applies to DataBlock, DeDuplicationTable (v1), and DeDuplicationTable2.

Verified against fixtures created by Aaru 5.3 (v1) and aaruformattool (v2).

Tests added (14 total, VerifyImageFixture suite):
- Happy path: floptical/mf2hd/cdmode1 for both v1 and v2 (6 tests)
- Invalid context: NULL and garbage (2 tests)
- Corruption detection: data block v1/v2, TracksBlock (3 tests)
- Index corruption: invalid offset, bad signature (2 tests)
- Programmatic round-trip: create + write + close + verify (1 test)
2026-04-01 20:49:25 +02:00