Skip to content

Fix RNC fail-open path and palette bounds compile error#127

Merged
segrax merged 1 commit into
masterfrom
codex/fix-undefined-std-size-in-graphics_amiga.cpp
May 24, 2026
Merged

Fix RNC fail-open path and palette bounds compile error#127
segrax merged 1 commit into
masterfrom
codex/fix-undefined-std-size-in-graphics_amiga.cpp

Conversation

@segrax
Copy link
Copy Markdown
Member

@segrax segrax commented May 24, 2026

Motivation

  • A recent change caused recognized-but-invalid RNC resources to be returned as the original compressed buffer on validation or decompression failure, enabling downstream unbounded memcpy into fixed-size arrays and leading to memory corruption.
  • The code also failed to build on some toolchains due to use of std::size on a raw array in Graphics_Amiga.cpp.

Description

  • In Source/Resources.cpp added an InvalidRNC helper that returns an empty shared byte buffer and changed the header/size validation and rnc_unpack mismatch branches to return InvalidRNC() instead of pBuffer, so malformed or failed-to-decompress RNC resources produce an empty buffer rather than attacker-controlled compressed bytes.
  • In Source/Amiga/Graphics_Amiga.cpp replaced std::size(Result.mPalette) with a portable capacity calculation sizeof(Result.mPalette) / sizeof(Result.mPalette[0]) before writing palette entries to fix the compile error.
  • No other functional changes were introduced to resource loading callsites in this patch.

Testing

  • Attempted to build the target with cmake --build . --target openfodder -j4, but the build could not be executed in this environment due to a missing CMake cache (Error: could not load cache).

Codex Task

@segrax segrax merged commit 56bec11 into master May 24, 2026
2 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant