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: compare unsanitized number using gte #1570

Closed
wants to merge 1 commit into from

Conversation

wemeetagain
Copy link
Member

If maxConnections is passed in as a float, this will result in disconnecting all peers due to this strict equality check.

This may happen unintentionally if maxConnections is set dynamically.

This is a patch to avoid this unfortunate failure mode.

Likely more thought should go into a systematic approach to handling these situations.

Copy link
Member

@maschad maschad left a comment

Choose a reason for hiding this comment

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

I can't conceptualize a fraction of a connection so I would suggest we convert any value set as maxConnections to a positive integer value internally - using something like Math.trunc - before we perform operations with that value.

@maschad
Copy link
Member

maschad commented Jan 30, 2023

I opened up #1572 in favour of this solution

@wemeetagain
Copy link
Member Author

Yea opened this PR mainly for discussion.

I think ideally we can/should validate user options in some more systematic way. Not sure about coersing user values, that could cause some confusion. Perhaps better to just throw when they are invalid.

@maschad
Copy link
Member

maschad commented Jan 31, 2023

I think ideally we can/should validate user options in some more systematic way. Not sure about coersing user values, that could cause some confusion. Perhaps better to just throw when they are invalid.

Agreed. That was also the suggestion made here

@achingbrain
Copy link
Member

Closing as we are going to implement more comprehensive config validation - #1573

@achingbrain achingbrain deleted the fix/strict-equal-compare branch February 14, 2023 16:53
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.

3 participants