Commit Graph

3 Commits

Author SHA1 Message Date
Fabio Scotto di Santolo
381f7b242d Report crc32 failure through the return value, not a sentinel
crc32 returned 0 both for a read error and as a genuine checksum, so the
caller had to remember to test ferror separately. That is precisely how
the descriptor leak fixed in 9e65819 got in.

The ambiguity is not hypothetical: an empty file checksums to exactly 0,
and create writes one for every empty file it walks.

Take a uint32_t out parameter and return 0/-1 instead.

Verified byte-identical snapshots against the previous build, and the
values still agree with zlib.crc32 for both an empty and a 100KB file.
A read failure still surfaces: create over a symlink to a directory
reports "Is a directory".

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018KyCHPAxWzqa3vHKdXJkgx
2026-08-26 15:36:29 +02:00
Fabio Scotto di Santolo
c397728912 Unify error handling: output parameter, goto cleanup, errno preservation
- Replace global field variable with output parameter enum Fields *err
- Adopt single goto cleanup pattern across all functions
- Add errno preservation around cleanup in all modules
- Fix early return bug in create.c cleanup block
- Add ferror check in crc32() for silent read errors
- Document error contracts in all public headers
2026-08-26 14:20:00 +02:00
Fabio Scotto di Santolo
e5f5d559bc Add CRC-32 fingerprinting of symlink targets
Hash the followed target content with CRC-32 (hash.c/hash.h) and emit a FINGERPRINT field for non-directory records in create.c. Schema: TYPE|MODE|UID|GID|MTIME|SIZE|FINGERPRINT|TARGET per SPEC §17/§18.
2026-08-23 17:47:09 +02:00