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

Wrong selector for the error `MathMasters__MulWadFailed()`

Summary

The functions mulWad(uint256 x, uint256 y) and mulWadUp(uint256 x, uint256 y) have the wrong selector for an error MathMasters__MulWadFailed() which leads to uninformative output when an error occurs.

Vulnerability Details

The functions mulWad(uint256 x, uint256 y) and mulWadUp(uint256 x, uint256 y) have the wrong selector 0xbac65e5b that corresponds to MulWadFailed() but not for the existing error MathMasters__MulWadFailed().

Impact

Uninformative output when an error occurs.

Tools Used

Manual review.

Recommendations

/// @dev Equivalent to `(x * y) / WAD` rounded down.
function mulWad(uint256 x, uint256 y) internal pure returns (uint256 z) {
// @solidity memory-safe-assembly
assembly {
// Equivalent to `require(y == 0 || x <= type(uint256).max / y)`.
if mul(y, gt(x, div(not(0), y))) {
- mstore(0x40, 0xbac65e5b) // `MathMasters__MulWadFailed()`.
+ mstore(0x40, 0xa56044f7) // `MathMasters__MulWadFailed()`.
revert(0x1c, 0x04)
}
z := div(mul(x, y), WAD)
}
}
/// @dev Equivalent to `(x * y) / WAD` rounded up.
function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
// Equivalent to `require(y == 0 || x <= type(uint256).max / y)`.
if mul(y, gt(x, or(div(not(0), y), x))) {
- mstore(0x40, 0xbac65e5b) // `MathMasters__MulWadFailed()`.
+ mstore(0x40, 0xa56044f7) // `MathMasters__MulWadFailed()`.
revert(0x1c, 0x04)
}
if iszero(sub(div(add(z, x), y), 1)) { x := add(x, 1) }
z := add(iszero(iszero(mod(mul(x, y), WAD))), div(mul(x, y), WAD))
}
}
Updates

Lead Judging Commences

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

Wrong error selector

Support

FAQs

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