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: throw error when encoding/decoding PONG with invalid port #218

Merged
merged 1 commit into from
Nov 2, 2022
Merged

fix: throw error when encoding/decoding PONG with invalid port #218

merged 1 commit into from
Nov 2, 2022

Conversation

jtraglia
Copy link
Contributor

@jtraglia jtraglia commented Nov 2, 2022

According to the spec, recipient-port is an (unsigned) 16-bit integer. This PR ensures that those port values are valid.

  • Remove a commented out line of code, doesn't seem useful to keep.
  • When decoding, check that the length of the field isn't greater than 2 bytes.
  • When encoding, check that the number is in the valid port range.
  • Add a test for encoding a PONG message with a 1-byte port.
  • Add a new test function that handles invalid messages.

@jtraglia jtraglia requested a review from a team as a code owner November 2, 2022 18:28
@jtraglia jtraglia changed the title Throw error when encoding/decoding PONG with invalid port fix: throw error when encoding/decoding PONG with invalid port Nov 2, 2022
Copy link
Member

@wemeetagain wemeetagain left a comment

Choose a reason for hiding this comment

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

🙏

@wemeetagain wemeetagain merged commit cfc3c3c into ChainSafe:master Nov 2, 2022
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