Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: high
Valid

Incorrect constant number used inside square root function for comparison.

Summary

sqrt function of MathMasters library uses incorrect constant value for comparison, which leads to wrong answer for certain cases.

Vulnerability Details

The vulnerability occurs due to the usage of wrong value for comparison.
At line 77, constant value 16777002 is used instead of 16777215.

Impact

Value of r calculated at line 77 will be incorrect for some test cases and will lead to wrong answer.

Tools Used

Manual Review

Recommendations

Change 16777002 to 16777215 at line 77.

-r := or(r, shl(4, lt(16777002, shr(r, x))))
+r := or(r, shl(4, lt(16777215, shr(r, x))))
Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Sqrt yields incorrect results for certain inputs because 16777002 doesn't represent the maximum value resulting from a right shift

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.