Fix eos_crc32 signature mismatch and duplicate variable in recovery write path - #65
Conversation
Correct diagnosis — and you are the fourth person to find itBoth defects are real. I confirmed the first independently before seeing this PR:
The overlap you should know aboutFour PRs now fix this same breakage: #55, #57, #58 and this one. That is not a criticism of any of them — I have approved #58, and would like it to land first. It is the widest: besides Both of your defects are in #58's set, so after it lands this branch reduces to nothing. I would rather say that plainly than leave it open looking like it still has work in it. What I would rather have from youIf you want a follow-up in the same area, the thing #58 does not do is stop this recurring.
Either would be worth more than this fix, because they prevent the next four PRs. VerificationConfirmed Blocker outside this PReBoot sets |
|
Thanks for the clear explanation and detailed context, @srpatcha! Makes complete sense to close this in favor of #58 since it covers I'll look into setting up host-target CI compilation as a follow-up, Closing this branch in favor of #58. |
Problem
Two independent bugs currently block the eBoot host build
(cmake -DEBLDR_BUILD_TESTS=ON) from compiling:
include/eos_image.h declared eos_crc32() as
int eos_crc32(uint32_t addr, size_t len, uint32_t *out);but this disagreed with both the function's own doc comment
just above it (which describes a 2-argument function that
returns the CRC32 value directly) and the actual implementation
in core/image_verify.c (
uint32_t eos_crc32(uint32_t addr, size_t len)). No caller anywhere in the codebase uses the3-argument form — this was a stale/copy-pasted prototype from
the sibling function eos_crc32_checked().
core/recovery.c's recovery_handle_write() declared
uint32_t slot_size = eos_hal_slot_size(slot);twice in thesame function — once near the top, and again immediately before
a later bounds-check comment (apparently left over from when
that bounds check was added). The redeclaration is a compile
error under MSVC (and a redundant no-op under GCC).
Approach
own documentation and the real implementation.
keeping the existing one and its later use in the bounds check
unchanged.
Testing
Built with MSVC (Visual Studio 2026 Build Tools, cmake -B build_test
-DEBLDR_BUILD_TESTS=ON) and confirmed both core/image_verify.c and
core/recovery.c compile with zero errors and zero warnings.
Limitations / additional considerations
While verifying the fix, I found a separate, unrelated, pre-existing
bug in core/ed25519_verify.c: eos_ed25519_verify() contains what
appears to be leftover code from an incomplete merge — a duplicate,
inconsistent "compute k" block (referencing types/functions like
sha512_ctx_t and sc_reduce that don't exist elsewhere in the file),
and the function's actual signature-verification comparison (the
diffvariable it returns) is never computed. Checking git blame,this has been present since the file was first added, so there's no
earlier working version to restore. I did not attempt to fix this as
part of this PR: this is the codebase's signature-verification logic
for trusted boot, and a mistaken "fix" here would be far worse than
a build error, since incorrect signature verification can silently
accept unauthorized firmware. This deserves focused review by
someone who can verify the cryptographic correctness of the fix,
rather than a quick patch.