The mulWadUp
never catches arithmatic overflow.
The assembly operation in line 52 of MathMasters.sol
always results in 0. Thus code block below it never runs, which means it cannot catch overflow.
The reason is
or(div(not(0), y), x)
is always greater than or equal to x.
x
never be greater than or(div(not(0), y), x)
, gt(x, or(div(not(0), y), x))
returns 0.
mul(y, 0)
returns 0.
0
is false
in boolean, thus code inside if
block is unreachable.
The test below represents the case when revert by overflow must happen but mulWadUp
doesn't catch it.
Add the test in MathMasters.t.sol
and run forge test -vvvv --mt testMulWadUpNeverCatchOverflow
to see the result.
All other contracts utilizing this library will be broken by unexpected overflow.
Foundry
Remove the or
opcode.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.