4 Commits

Author SHA1 Message Date
bbae748612 Fix data race in StuffIt X English dictionary initialization
The shared English word dictionary was built behind a plain `if(dict_ptrs)`
guard, which provides neither mutual exclusion nor memory ordering. Worse,
dict_ptrs was published by malloc before the pointer table was populated, so a
concurrent caller of the exported AARU_stuffitx_english_decode_buffer could
pass the guard and read uninitialized pointers. Two racing threads would also
both run the full PPMd decode, leaking the dictionary buffer.

Build the dictionary in locals and publish the statics only once the table is
complete, driven by pthread_once (POSIX) or InitOnceExecuteOnce (Windows), and
record the outcome so a failed build is never retried.

Also fix three adjacent issues in the same path: the word-scan loop
dereferenced p before bounds-checking it, the base-52 index accumulator could
overflow into a value that passed the bounds check, and the word buffer clamp
left no room for the appended terminator character.

Same class of bug as MacPaw/XADMaster#194.
2026-08-31 12:06:34 +01:00
16dd2ce90f Add ShrinkWrap 3 SIT2 decompression support and tests 2026-04-20 14:43:39 +01:00
c5af197a63 Enhance StuffIt X decoding functions to track consumed input size, fixes Blend algorithm 2026-04-17 17:30:55 +01:00
ba39191e07 Add StuffIt decompression support
- Implemented range coder in `rangecoder.c` and `rangecoder.h` for efficient encoding/decoding.
- Added RLE90 decoding in `rle90.c` for handling StuffIt method 1.
- Introduced `stuffit.h` and `stuffit_internal.h` to define compression methods and internal structures.
- Implemented x86 address transformation in `x86.c` for StuffIt X preprocessing.
- Updated CMakeLists to include new test data files for various StuffIt methods.
- Created comprehensive tests in `stuffit.cpp` for validating decompression of multiple StuffIt formats.
- Added binary test data for StuffIt methods including compress, method 13, arsenic, and StuffIt X variants.
2026-04-17 01:19:44 +01:00