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
2025-07-31 09:50:10 +01:00
2026-03-14 18:52:30 +00:00
2026-03-19 08:45:07 +01:00
2025-10-11 14:06:30 +01:00
2024-04-30 15:51:47 +01:00
2025-12-23 08:23:40 +00:00
2019-03-16 17:40:39 +00:00

libaaruformat

C implementation of Aaru file format.

The target is to be able to compile it with a normal C (C89 compliant) compiler.

There are no external dependencies.

cmake is not a hard dependency, it's merely for the ease of using IDEs (specifically CLion).

Currently supported features:

  • AaruFormat V1 images reading (writing will never be implemented)
  • AaruFormat V2 images reading and writing
  • LZMA compression
  • Claunia Subchannel Transform
  • Optical disc tracks
  • XML metadata retrieval (writing will never be implemented)
  • JSON metadata retrieval and writing
  • Hashing while writing (MD5, SHA1, SHA256, SpamSum and BLAKE3)
  • Deduplication
  • Tape file and partitions
  • Dump hardware lists
  • Currently on sync (as of October 2025) with Aaru's media type list
  • CHS geometry retrieval and setting
  • Metadata
  • Unit testing
  • Automatic generation of API documentation
  • It is to all effects feature parity with C#

Things still to be implemented that are already in the C# version:

  • Automatic media type generation from C# enumeration
  • Nuget package for linking with Aaru

Things to be implemented not in the C# version (maybe):

  • Compile for Dreamcast (KallistiOS preferibly)
  • Compile for PlayStation Portable
  • Compile for Wii
  • Compile for Wii U
  • Compile for PlayStation 2
  • Compile for PlayStation 3
  • Snapshots
  • Parent images
  • Data positioning measurements

Building and Testing

Standard Build

mkdir build
cd build
cmake ..
cmake --build .

Running Tests

cd build
ctest --verbose

Building with Address Sanitizer

For debugging memory issues, you can build with Address Sanitizer enabled:

mkdir build-asan
cd build-asan
cmake -DUSE_ASAN=ON -DCMAKE_BUILD_TYPE=Debug ..
cmake --build .
ctest --verbose

For detailed information on using Address Sanitizer to detect memory issues, see docs/ASAN_USAGE.md.

Other Build Options

  • -DUSE_SLOG=ON - Enable slog logging for debugging
  • -DUSE_ASAN=ON - Enable Address Sanitizer for memory error detection
Description
C implementation of Aaru file format.
Readme LGPL-2.1 78 MiB
Languages
C 90.4%
C++ 8.1%
CMake 1.2%
Shell 0.2%
PowerShell 0.1%