fix(recovery): validate UART write bounds with helper - #74
Merged
srpatcha merged 2 commits intoAug 31, 2026
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
TASKS.md verification commands use Windows-style path separators that are likely not runnable in the repo’s POSIX-oriented workflows, reducing verifiability.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Introduces and adopts a shared bounds-validation helper for UART recovery WRITE packets to prevent out-of-slot and address-wrap flash writes.
Changes:
- Add
eos_recovery_write_in_range()helper to validate(base, slot_size, offset, len)including overflow cases. - Update
recovery_handle_write()to use the helper and remove the duplicateslot_sizedeclaration. - Add unit tests covering helper boundary/overflow behavior and keep the existing out-of-bounds WRITE regression test.
File summaries
| File | Description |
|---|---|
| core/recovery.c | Adds the bounds helper and uses it in the UART WRITE handler before ACK/flash write. |
| tests/unit/test_recovery.c | Adds a unit test for the new bounds helper and wires it into main(). |
| TASKS.md | Adds/updates task T-007 with acceptance criteria and verification notes for the change. |
Review details
Suppressed comments (1)
TASKS.md:50
- The Python verification command uses Windows-style path separators (
tests\unit\...), which is likely to fail on POSIX shells. Use forward slashes so the command is portable and matches the repository's documented commands.
| Build | `cmake -B build -DEBLDR_BUILD_TESTS=ON` | `UNKNOWN` - `cmake` is not installed in this environment |
| Unit test | `ctest --test-dir build --output-on-failure -R test_recovery` | `UNKNOWN` - `ctest` is not installed in this environment |
| Python unit tests | `pytest tests\unit\test_uart_recovery.py tests\unit\test_sign_image.py` | `UNKNOWN` - `pytest` is not installed in this environment |
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+45
to
+46
| | Static check - duplicate slot size | `rg "uint32_t slot_size = eos_hal_slot_size" core\recovery.c` | `PASS` - one declaration remains | | ||
| | Static check - helper use | `rg "eos_recovery_write_in_range" core\recovery.c tests\unit\test_recovery.c` | `PASS` - helper is defined, called by `recovery_handle_write()`, and covered by tests | |
srpatcha
previously approved these changes
Aug 31, 2026
srpatcha
self-requested a review
August 31, 2026 08:02
srpatcha
approved these changes
Aug 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix recovery UART WRITE bounds validation by routing the handler through the existing
eos_recovery_write_in_range()helper before acknowledging or writing data to flash.Type of Change
Changes
slot_sizedeclaration inrecovery_handle_write().recovery_handle_write()to calleos_recovery_write_in_range()before sending the ready ACK.uint32_taddress wrap.Testing
Validation performed locally:
git diff --checkpassed with only CRLF normalization warnings.slot_sizedeclaration remains.recovery_handle_write()callseos_recovery_write_in_range().Not run locally:
cmake -B build -DEBLDR_BUILD_TESTS=ONcmake --build build --parallelctest --test-dir build --output-on-failure -R test_recoveryReason:
cmake,ctest, andpytestare not installed in my local environment.Pre-Submission Checklist
<type>(<scope>): <description>conventionRelated Issues
None.
Screenshots / Logs
Not applicable.
Additional Notes
A separate review pass found no issues in the diff. The remaining limitation is that the C build and CTest suite still need to be run in CI or on a machine with the required toolchain installed.