Skip to content

Conversation

@bruingineer
Copy link
Contributor

Fix logic bug that wrongly accepts packets when wrapping the u8 sequence number range.

old seq number: 1
new seq number 254

e1.31 spec says to discard since it is within the -20, 0 difference range.

current seq diff on main: 254 - 1 = 253 as isize
accepted incorrectly

this pr: 254 - 1 = 253 as i8 = -3
-3 is within the discard window, so it correctly discards the packet.

@bruingineer bruingineer mentioned this pull request Dec 27, 2025
10 tasks
stewartadam
stewartadam previously approved these changes Dec 28, 2025
Copy link
Contributor

@stewartadam stewartadam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look good, thank you for adding the test to validate the fix as well!

src/receive.rs Outdated
Comment on lines 3313 to 3315
//
// Current implementation likely FAILS because it computes diff using normal
// integer subtraction rather than signed 8-bit arithmetic.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//
// Current implementation likely FAILS because it computes diff using normal
// integer subtraction rather than signed 8-bit arithmetic.
//
// Current implementation likely FAILS because it computes diff using normal
// integer subtraction rather than signed 8-bit arithmetic.

To avoid the docstring falling out of date, I suggest removing this. The test pass/fail will track correct behavior and if our implementation follows it.

@stewartadam stewartadam merged commit 4c527b2 into RustLight:main Dec 29, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants