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 error in integer_parser (fixes #290) #417

Merged
merged 1 commit into from
Feb 1, 2024

Conversation

ololuki
Copy link
Contributor

@ololuki ololuki commented Jan 17, 2024

Checking for overflow should be done before integer overflows.

There are two checks:

  • (result > limit / base) is used for limits greater than rounded up to base, e.g. for 65535 it will activate for 65540 and higher.
  • (result * base > limit - digit) is used for limit+1 to limit+n below next base rounded number, e.g. 65536 up to 65539.

fixes #290


This change is Reviewable

Checking for overflow should be done before integer overflows.
There are two checks:
(result > limit / base) is used for limits greater than rounded up to base,
e.g. for 65535 it will activate for 65540 and higher.
(result * base > limit - digit) is used for limit+1 to limit+n below
next base rounded number, e.g. 65536 up to 65539.
@jarro2783
Copy link
Owner

Thanks for looking at this and fixing it for me.

@jarro2783 jarro2783 merged commit e84ab5f into jarro2783:master Feb 1, 2024
10 checks passed
@ololuki ololuki deleted the fix_integer_parser_overflow branch April 20, 2024 10:58
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.

out of range argument not detected
2 participants