Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix overflow issues in seqNr and ackNr #692

Merged
merged 4 commits into from
Dec 17, 2024
Merged

Conversation

acolytec3
Copy link
Collaborator

@acolytec3 acolytec3 commented Dec 16, 2024

This addresses #691.

The Problem

uTP sequence numbers are 16 bit unsigned integers so have a range of 0-65535. When a sequence number reaches the maximum value, we would expect the next sequence number to be 0. Ultralight was not checking for overflow and blithely continuing on in the sequence since we are using native Javascript numbers in our code rather than true 16-bit intengers.

Solution

  • Revise contentWriter sodataChunks are stored in an array of tuples of the form [seqNr, bytes] rather than an object keyed by the seqNr
  • Check for overflow in all sequence and ack number checks and updates
  • Convert some Object.keys code to simple Array accesses (which should provide some small performance boost)
  • Removes writeSocket.dataNrs as unnecessary

@acolytec3 acolytec3 linked an issue Dec 16, 2024 that may be closed by this pull request
Copy link
Collaborator

@ScottyPoi ScottyPoi left a comment

Choose a reason for hiding this comment

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

LGTM

@ScottyPoi ScottyPoi merged commit c7e5cf8 into master Dec 17, 2024
5 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.

Deal with data packet numbers at maxInt
2 participants