fix(relinker): require a full ELF64 header before reading it #183

Merged
arreina merged 1 commit from upstream-pr/183 into main 2026-09-30 19:03:27 +00:00
arreina commented 2026-09-30 12:09:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by arreina on 2026-09-30T12:09:02Z.


What

ElfReader::ReadHeader reads fields up to offset 0x40 but only rejected inputs shorter than 20 bytes. A truncated ELF (20–63 bytes) failed with FileByteOffset out of bounds (offset 0x20) instead of File too small for ELF header. The check now requires the full 64-byte ELF64 header. test_elf_header.py covers tiny, truncated, header-only and bad-magic inputs with synthetic bytes.

Tested

Linux (Ubuntu 24.04, GCC 13.3): full build, ctest 65/65 passed. The new test fails without the fix and passes with it. No title used.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt — n/a
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source — none
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes. I'm new to the project; happy to adjust anything.

🤖 Generated with Claude Code

https://claude.ai/code/session_01R5WJS4ZdQynAJesCZKH5hb

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4690249192 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/183). Originally posted by [arreina](https://github.com/arreina) on 2026-09-30T12:09:02Z. --- ### What `ElfReader::ReadHeader` reads fields up to offset 0x40 but only rejected inputs shorter than 20 bytes. A truncated ELF (20–63 bytes) failed with `FileByteOffset out of bounds (offset 0x20)` instead of `File too small for ELF header`. The check now requires the full 64-byte ELF64 header. `test_elf_header.py` covers tiny, truncated, header-only and bad-magic inputs with synthetic bytes. ### Tested Linux (Ubuntu 24.04, GCC 13.3): full build, `ctest` 65/65 passed. The new test fails without the fix and passes with it. No title used. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt — n/a - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source — none - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes. I'm new to the project; happy to adjust anything. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01R5WJS4ZdQynAJesCZKH5hb
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
boykopovar/AnyPS5!183
No description provided.