Skip to content

Conversation

djelinski
Copy link

The decoding method described in RFC 9000 treats the encoded packet number as a signed integer. We need to encode the sign bit to ensure correct decoding when 128+ packets are lost.

This PR fixes the packet number length computation, and adds a test to verify that the returned packet length is sufficient to decode the next packet number assuming a loss of 1..254 packets.

Fixes #2180

@djelinski djelinski requested a review from a team as a code owner October 6, 2025 06:16
@ghedo
Copy link
Member

ghedo commented Oct 13, 2025

As far as I understand, this will mean we never use 1-byte encoding? It's not necessarily a huge issue, but I also don't really think it's the correct fix...

@djelinski
Copy link
Author

Thanks @ghedo for the review. We still use 1-byte encoding for packet numbers between base+1 and base+126; the change makes the encoding one bit longer, not one byte longer.

@ghedo ghedo enabled auto-merge (squash) October 13, 2025 16:27
Copy link
Member

@ghedo ghedo left a comment

Choose a reason for hiding this comment

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

Oh, you are right 🤦 Looks good to me.

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.

Incorrect packet number encoding

2 participants