code-423n4 / 2022-01-sherlock-findings

0 stars 0 forks source link

Skip checking booleans against true / false #212

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

GreyArt

Vulnerability details

Impact

Instead of doing if (X == true) or if (X == false), it is more gas efficient to do if (X) or if (!X).

Instances

Manager.sweep()

// Sends any remaining ETH to the receiver address (as long as receiver address is payable)
(bool success, ) = _receiver.call{ value: address(this).balance }('');
if (success == false) revert InvalidConditions();

SherClaim.claim()

// Only allow claim calls if claim period is active
if (!active()) revert InvalidState();

SherlockClaimManager.cleanUp()

if (_isCleanupState(_oldState) == false) revert InvalidState();

SherlockClaimManager.escalate()

// Can this claim be updated (based on its current state)? If no, revert
if (_isEscalateState(_oldState, updated) == false) revert InvalidState();

Recommended Mitigation Steps

Manager.sweep()

// Sends any remaining ETH to the receiver address (as long as receiver address is payable)
(bool success, ) = _receiver.call{ value: address(this).balance }('');
if (!success) revert InvalidConditions();

SherClaim.claim()

// Only allow claim calls if claim period is active
if (!active()) revert InvalidState();

SherlockClaimManager.cleanUp()

if (!_isCleanupState(_oldState)) revert InvalidState();

SherlockClaimManager.escalate()

// Can this claim be updated (based on its current state)? If no, revert
if (!_isEscalateState(_oldState, updated)) revert InvalidState();
jack-the-pug commented 2 years ago

Dup #132