Skip to content

[RTU-01C] Improper Evaluation of Assert #15

@dkuppitz

Description

@dkuppitz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions