Add EWAD format, status codes and embeddable build #1

Merged
fputs merged 3 commits from fputs/ewad into master 2026-11-08 12:07:10 -08:00 AGit
Owner

Summary

  • Adds the EWAD type: 63-byte names, duplicate lumps in insertion order, deterministic output, and strict validation on load.
  • Parses and writes WAD2 and WAD3 with their real 32-byte directory entries, keeping the lump type byte in Lump.kind.
  • Replaces stderr output with distinct status codes and wad_status_name.
  • Makes loading transactional, and fixes NULL lump data, u32 write limits, unknown-type writes, and fseek/ftell/empty-file handling.
  • Makes the build usable through add_subdirectory: CMake 3.17, C11, SPITWAD_SANITIZE, and tests only when top-level. Adds an MIT LICENSE.
  • Adds docs/spitwad.md and docs/WAD Format.md, and a CI job that runs the tests under ASan and UBSan.

Behaviour changes

  • wad_load_file and wad_load_data do not need wad_init and do not free what the WAD held. Call wad_destroy before reloading a populated WAD.
  • Types other than EWAD truncate names on add (8 bytes classic, 15 for WAD2/WAD3), and truncate the query the same way on lookup and removal. EWAD compares whole names.
  • Classic files whose directory or non-empty lumps overlap the header are now rejected.
  • A load fails as SPITWAD_ERR_MALFORMED if lumps total more than 16 times the input size or more than UINT32_MAX bytes, which bounds memory use on crafted files.
  • Compressed WAD2/WAD3 lumps return the new SPITWAD_ERR_UNSUPPORTED. Status codes also include SPITWAD_ERR_NOT_FOUND and SPITWAD_ERR_TOO_LARGE.

Testing

  • 29/29 CTest cases pass in a Debug build and with SPITWAD_SANITIZE=ON, on macOS and on Alpine 3.24 with leak detection on.
  • WAD2/WAD3 are tested against hand-built bytes, not real Quake or Half-Life files.

Known gaps

  • Files with the PACK signature are parsed with the classic layout, so real PAK files are misread.

🤖 Generated with Claude Code

## Summary - Adds the `EWAD` type: 63-byte names, duplicate lumps in insertion order, deterministic output, and strict validation on load. - Parses and writes WAD2 and WAD3 with their real 32-byte directory entries, keeping the lump type byte in `Lump.kind`. - Replaces stderr output with distinct status codes and `wad_status_name`. - Makes loading transactional, and fixes NULL lump data, u32 write limits, unknown-type writes, and `fseek`/`ftell`/empty-file handling. - Makes the build usable through `add_subdirectory`: CMake 3.17, C11, `SPITWAD_SANITIZE`, and tests only when top-level. Adds an MIT LICENSE. - Adds `docs/spitwad.md` and `docs/WAD Format.md`, and a CI job that runs the tests under ASan and UBSan. ## Behaviour changes - `wad_load_file` and `wad_load_data` do not need `wad_init` and do not free what the WAD held. Call `wad_destroy` before reloading a populated WAD. - Types other than EWAD truncate names on add (8 bytes classic, 15 for WAD2/WAD3), and truncate the query the same way on lookup and removal. EWAD compares whole names. - Classic files whose directory or non-empty lumps overlap the header are now rejected. - A load fails as `SPITWAD_ERR_MALFORMED` if lumps total more than 16 times the input size or more than `UINT32_MAX` bytes, which bounds memory use on crafted files. - Compressed WAD2/WAD3 lumps return the new `SPITWAD_ERR_UNSUPPORTED`. Status codes also include `SPITWAD_ERR_NOT_FOUND` and `SPITWAD_ERR_TOO_LARGE`. ## Testing - 29/29 CTest cases pass in a Debug build and with `SPITWAD_SANITIZE=ON`, on macOS and on Alpine 3.24 with leak detection on. - WAD2/WAD3 are tested against hand-built bytes, not real Quake or Half-Life files. ## Known gaps - Files with the `PACK` signature are parsed with the classic layout, so real PAK files are misread. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Add EWAD format, status codes and embeddable build
All checks were successful
test / test (pull_request) Successful in 9s
55e5a88f14
Add the EWAD type with 63-byte names, duplicate lumps and strict
validation on load. Replace stderr output with distinct status codes
and wad_status_name.

Make loading transactional and free any previous lumps, so wad_init
is now required before wad_load_file and wad_load_data. Compare whole
names in lookup and removal, use 64-bit range checks, refuse output
past the u32 range and unknown types, and check fseek, ftell and
fclose.

Lower the CMake minimum to 3.17, build the library as C11, add
SPITWAD_SANITIZE, and only build tests when top-level. Add the MIT
license.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fix review findings, add real WAD2/WAD3 layout and docs
Some checks failed
test / sanitize (push) Failing after 10s
test / test (push) Successful in 12s
f6cb20b14d
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pin CI to alpine:3.24
All checks were successful
test / test (push) Successful in 11s
test / test (pull_request) Successful in 14s
test / sanitize (pull_request) Successful in 14s
test / sanitize (push) Successful in 9s
4898c6e876
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fputs merged commit e0d6541447 into master 2026-11-08 12:07:10 -08:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
fputs/spitwad!1
No description provided.