esp: improve oseq overflow handling.#80
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves ESP outbound sequence-number (oseq) overflow handling and adds a unit test to validate the overflow behavior, addressing F-696.
Changes:
- Initialize ESP outbound replay sequence (
oseq) to 0 so the first transmitted sequence becomes 1 after pre-increment. - Pre-increment
oseqduringesp_transport_wrap()and reject the wrap-around-to-0 case. - Add a unit test that drives
oseqtoESP_MAX_32_SEQand asserts the overflow wrap is rejected.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
wolfesp.h |
Adjusts replay initialization to start outbound sequence counter at 0. |
src/wolfesp.c |
Updates outbound sequence increment/overflow check in ESP transport wrapping. |
src/test/unit/unit_esp.c |
Adds and registers a unit test covering oseq overflow rejection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Improves ESP outbound sequence number (oseq) overflow handling to prevent wrap-around/reuse, and adds a unit test to validate the behavior (Fixes F-696).
Changes:
- Initialize outbound
replay.oseqto 0 so the first transmitted ESP sequence is still 1 after the pre-increment behavior. - Detect
oseqoverflow duringesp_transport_wrap()and reject further transmissions by latchingoseqat max and returning-1. - Add a unit test that drives
oseqto the overflow boundary and asserts repeated rejection after overflow.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| wolfesp.h | Adjusts replay initialization so outbound oseq starts at 0 (works with pre-increment send semantics). |
| src/wolfesp.c | Moves oseq increment before writing SEQ and adds overflow detection that prevents wrap-around reuse. |
| src/test/unit/unit_esp.c | Adds test_replay_overflow to verify overflow is detected and remains rejected on subsequent wraps. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Description
Improve ESP oseq overflow handling.
Add unit test to check overflow.
Fixes F-696.