You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// @notice versions >=0.8.0 && <0.8.17function checkedMulInt(int256a, int256b) publicpurereturns (int256c) {
unchecked {
c = a * b;
if (a >0&& b >0&& a >type(int256).max / b) arithmeticError();
if (a >0&& b <0&& a <type(int256).min / b) arithmeticError();
if (a <0&& b >0&& a <type(int256).min / b) arithmeticError();
if (a <0&& b <0&& a <type(int256).max / b) arithmeticError();
}
}
There is an issue on the third condition that should be replaced :
/// @notice versions >=0.8.0 && <0.8.17
function checkedMulInt(int256 a, int256 b) public pure returns (int256 c) {
unchecked {
c = a * b;
if (a > 0 && b > 0 && a > type(int256).max / b) arithmeticError();
if (a > 0 && b < 0 && a < type(int256).min / b) arithmeticError();
- if (a < 0 && b > 0 && a < type(int256).min / b) arithmeticError();+ if (a < 0 && b > 0 && a > type(int256).min / b) arithmeticError();
if (a < 0 && b < 0 && a < type(int256).max / b) arithmeticError();
}
}
I discovered this issue while trying to use the code block for the solution of nodeGuardian's yul assembly quest.
Let me know if you need more details.
The text was updated successfully, but these errors were encountered:
At this page : https://github.com/crytic/building-secure-contracts/blob/master/learn_evm/arithmetic-checks.md#arithmetic-checks-for-int256-multiplication
The first block of code is :
There is an issue on the third condition that should be replaced :
I discovered this issue while trying to use the code block for the solution of nodeGuardian's yul assembly quest.
Let me know if you need more details.
The text was updated successfully, but these errors were encountered: