858 Commits

Author SHA1 Message Date
112f53dc3d More 64-bit file offset fixes. 2026-04-04 16:32:25 +01:00
0d9e07a151 Add Windows compatibility for get_current_filetime function 2026-04-04 15:55:52 +01:00
65b88dab27 Add Windows compatibility for isatty and STDOUT_FILENO definitions 2026-04-04 15:55:15 +01:00
774ccbc8ae Fix tests compilation in MSVC. 2026-04-04 15:54:38 +01:00
509bb6026d Implement reentrant strtok function alias for compiler compatibility. 2026-04-04 15:53:45 +01:00
0ee5a97d23 Implement AARU_PREFETCH macro for improved prefetching across compilers 2026-04-04 15:53:03 +01:00
c06409b746 build: remap POSIX large-file APIs to native 64-bit stdio functions for MSVC
Allows libFLAC to compile in MSVC (how do they do it upstream? do they?)
2026-04-04 15:51:55 +01:00
1681c4f1ec build: enhance MSVC assembly handling for BLAKE3 with architecture checks 2026-04-04 15:51:03 +01:00
41ec943ffa build: add CMake presets for debug and release configurations 2026-04-04 15:49:57 +01:00
d39ffc2376 build: modify compare tool handling for Windows compatibility 2026-04-04 15:13:13 +01:00
d9c4a09972 build: enhance Windows build process by copying runtime DLLs and statically linking MinGW libraries 2026-04-04 15:12:47 +01:00
9c1d6d5e6f refactor: use AARU_ALIGN16 macro for 16-byte alignment in crc64_clmul.c and crc64_vmull.c 2026-04-04 15:11:13 +01:00
2aac1ce89c refactor: update file I/O to support large files with aaru_off_t type 2026-04-04 15:10:46 +01:00
31418a8511 On Win32 use SetLastError instead of setting errno. 2026-04-03 20:19:22 +01:00
7fb5f81f88 test: update PS3 encryption map to support 64 regions 2026-04-02 22:56:16 +01:00
e9fb0099ee build: enhance Windows test setup by copying runtime DLLs post-build 2026-04-02 22:54:38 +01:00
3718f88b53 Merge pull request #36 from RomTholos/refactor/split-metadata-reader-writer
refactor: split metadata.c into reader/writer
2026-04-02 22:52:20 +01:00
cf6821b8ba Merge pull request #35 from RomTholos/refactor/split-close-reader-writer
refactor: split close.c into reader/writer
2026-04-02 22:51:09 +01:00
6e8f1a3d65 Merge pull request #34 from RomTholos/test/identify
test: add aaruf_identify and aaruf_identify_stream tests
2026-04-02 22:48:24 +01:00
95571af03c Merge pull request #33 from RomTholos/test/mode2-regression
test: add Mode 2 CD read path regression tests
2026-04-02 22:47:03 +01:00
ae82b40815 Merge pull request #29 from RomTholos/test/zstd-compression-roundtrip
Test/zstd compression roundtrip
2026-04-02 22:43:53 +01:00
Kevin Bortis
59c1aebcae refactor: split metadata.c into reader/writer
Separate read-only metadata accessors from write-path mutators to
prepare for the dual-license split (MIT reader / LGPL writer).

metadata.c retains 20 aaruf_get_* functions: geometry, media sequence,
creator, comments, media title, media/drive manufacturer/model/serial/
barcode/part number, firmware revision, CICM metadata, Aaru JSON
metadata, user/negative/overflow sectors, and image info.

metadata_write.c receives 28 functions: 15 aaruf_set_* (geometry,
media sequence, creator, comments, media title, media/drive
manufacturer/model/serial/barcode/part number, firmware revision,
Aaru JSON metadata) and 13 aaruf_clear_* counterparts.

No shared static helpers between the two files. No behavioral change.
All functions are independent public API — no function pointer or
callback mechanism needed (unlike close.c which required a finalization
hook).

Verified:
- Builds cleanly, zero warnings
- 163/165 tests pass (2 pre-existing failures)
- metadata.o exports no set_/clear_ symbols
2026-04-02 09:31:15 +02:00
Kevin Bortis
d8ff7b4a28 refactor: split close.c into reader/writer
Separate writer finalization from resource cleanup in close.c to
enable a future reader-only library target (aaruformatread).

close_write.c contains all write_* helpers and aaruf_finalize_write().
close.c retains aaruf_close() with cleanup only, dispatching writer
finalization via a function pointer set by aaruf_create()/aaruf_open().

Zero behavioral change — same tests pass, same error semantics.
2026-04-02 08:32:10 +02:00
Kevin Bortis
79b2c0dff8 test: add Mode 2 CD read path regression tests
7 tests across two files covering three upstreamed Mode 2 bug fixes:

mode2_nocrc.cpp — fix/mode2-form2-nocrc-edc regression:
- NoCrcEdcBytesAreZero: Form 2 sectors with zero EDC read back with
  bytes 2348..2351 zeroed (not uninitialized). Uses poisoned buffer
  (0xCC fill) to detect missing memset.
- ValidEdcSurvivesRoundtrip: sanity check that valid-EDC sectors are
  not treated as NoCrc.
- MixedNoCrcAndValidEdcPerSector: alternating NoCrc/Ok sectors verify
  per-sector DDT suffix status tracking.

mode2_errored.cpp — fix/mode2-errored-suffix-read and
fix/mode2-form-detection-read regressions:
- ErroredForm2SuffixRestored: wrong EDC (0xDEADBEEF) survives roundtrip
  through the 4-byte suffix buffer for Form 2 errored sectors.
- ErroredForm1SuffixRestored: full 280-byte suffix (EDC+ECC) survives
  roundtrip for Form 1 errored sectors.
- MixedErroredForm1AndForm2: alternating forms in one track, verifying
  the DDT correctly dispatches per-sector.
- DisagreeingSubheaderUsesForm2: subheader copy 1 says Form 1, copy 2
  says Form 2 — verifies OR logic picks Form 2 and all 2324 bytes of
  user data are intact (old bug corrupted bytes 2072+).

All tests use programmatic fixtures via aaruf_create/write_sector_long
with crafted 2352-byte sectors — no external data files needed.
2026-04-02 07:56:21 +02:00
Kevin Bortis
2a2db120cf test: add aaruf_identify and aaruf_identify_stream tests
15 tests covering the image identification API:

- Happy path: valid V1 and V2 images via both file path and stream
- Error handling: NULL stream, empty file, truncated header
- Format validation: wrong magic bytes, future version, legacy DIC_MAGIC
- Stream behavior: mid-position seek-to-zero before reading
- File path errors: non-existent path, non-Aaru file, NULL path

Uses existing V1/V2 .aif fixtures from tests/data/ plus crafted
in-memory headers via tmpfile() for edge cases.
2026-04-02 07:55:58 +02:00
Kevin Bortis
910680fea9 Add zstd compression roundtrip tests 2026-04-02 07:47:39 +02:00
62202a5c29 Merge pull request #32 from RomTholos/fix/verify-v1-lzma-crc
Fix v1 image verification and add aaruf_verify_image tests
2026-04-01 22:41:49 +01:00
b38c92855f Merge pull request #31 from RomTholos/test/flac-error-handling
Add FLAC error handling regression tests
2026-04-01 22:40:31 +01:00
d75bb6f79d Merge pull request #30 from RomTholos/cmake/optional-tool-build
Make tool build optional (requires Argtable3)
2026-04-01 22:40:03 +01:00
bb3560b82c Merge pull request #28 from RomTholos/feat/zstd-all-sections
Extend zstd compression to all sections, add featureIncompatible bit
2026-04-01 22:37:53 +01:00
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
Kevin Bortis
5e00a01e21 Add FLAC error handling regression tests
Regression tests for the error handling improvements in
fix/flac-error-handling (PR #23). The fix changed decode/encode to
return 0 instead of (size_t)-1 on failure, added NULL allocation
checks, and fixed a decoder memory leak on init failure.

Tests added (flacErrors suite):
- decode_garbage_returns_zero: random non-FLAC data
- decode_truncated_flac_returns_zero: valid magic, truncated stream
- decode_empty_input_returns_zero: NULL source buffer
- decode_zero_length_returns_zero: non-NULL but zero-length source
- encode_zero_length_no_crash: NULL source, verifies no crash/leak
- encode_garbage_roundtrip_fails_cleanly: non-PCM encode + decode
- decode_dst_too_small_returns_zero: undersized output buffer

All tests are self-contained (no fixture files needed) and pass
under AddressSanitizer.
2026-04-01 20:24:13 +02:00
Kevin Bortis
6fabbefb30 Extend zstd compression to all sections, add featureIncompatible bit 2026-04-01 19:45:41 +02:00
Kevin Bortis
2b0e3b0a6e Make tool build optional (requires Argtable3) 2026-04-01 19:18:50 +02:00
6fa129282b Merge pull request #25 from RomTholos/fix/mode2-form-detection-read
fix Mode 2 form detection in errored-suffix read path
2026-04-01 16:03:02 +01:00
3cc1830a5f Merge pull request #20 from RomTholos/spec/document-lzma-properties-prefix
spec: clarify LZMA properties prefix in cmpLength and cmpCrc64 scope
2026-04-01 16:02:34 +01:00
Kevin Bortis
b88e71a865 fix Mode 2 form detection in errored-suffix read path 2026-03-31 19:40:47 +02:00
Kevin Bortis
2cbd88a15b spec: clarify LZMA properties prefix in cmpLength and cmpCrc64 scope 2026-03-31 08:59:52 +02:00
3af5f1ec41 Merge pull request #24 from RomTholos/fix/lzma-threading-cleanup
Replace hardcoded LZMA thread count with LZMA_THREADS(ctx)
2026-03-29 22:26:11 +01:00
0e79486a9e [spec] Add annex about Nintendo Wii U Disc Encryption 2026-03-29 19:47:03 +01:00
1172630c84 [spec] Add annex about Nintendo Wii Disc Encryption 2026-03-29 19:37:16 +01:00
88e4b7cf57 [spec] Add annex about GameCube / Wii junk. 2026-03-29 19:30:36 +01:00
ea669e4040 [spec] Add annex about PlayStation 3 encryption. 2026-03-29 19:19:37 +01:00
01e46f9e16 [spec] Add emojis to all headings. 2026-03-29 19:05:06 +01:00
1dcf9fb619 [spec] Add emojis to Annex A. 2026-03-29 19:00:19 +01:00
ee93001607 [spec] Register emoji font. 2026-03-29 18:56:17 +01:00
8adb38096f [spec] Fixed heading in compression. 2026-03-29 18:50:39 +01:00
e168226e9a [spec] Write media types annex. 2026-03-29 18:47:15 +01:00
bf9328f755 [spec] Added historical mistake block identifier. 2026-03-29 18:35:23 +01:00
530dac88a9 [spec] Fixed metadata block description. 2026-03-29 18:33:55 +01:00