-
Notifications
You must be signed in to change notification settings - Fork 1
[RTU-01C] Improper Evaluation of Assert #15
Copy link
Copy link
Open
Description
RTU-01C: Improper Evaluation of Assert
| Type | Severity | Location |
|---|---|---|
| Code Style | ![]() |
RebaseTokenUpgradeable.sol:L244 |
Description:
The RebaseTokenUpgradeable::_checkRebaseOverflow function will evaluate an assert statement that can never evaluate to false.
Example:
function _checkRebaseOverflow(uint256 shares, uint256 index) private view {
// The condition inside `assert()` can never evaluate `false`, but `toTokens()` would throw an arithmetic
// exception in case we overflow, and that's all we need.
assert(shares.toTokens(index) + ERC20Upgradeable.totalSupply() <= type(uint256).max);
}Recommendation:
While this is detailed in the assert statement's comments, we still advise the code to be wrapped in an unchecked code block and to instead ensure that the addition between shares.toTokens(index) and ERC20Upgradeable::totalSupply does not overflow thus ensuring that no code is unreachable.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
