Skip to content

Commit

Permalink
Merge pull request #1891 from crytic/fp/incorrect-shift
Browse files Browse the repository at this point in the history
do not detect incorrect-shift when rhs is constant
  • Loading branch information
montyly authored May 5, 2023
2 parents df0b7ce + e42408b commit c1ae06a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion slither/detectors/assembly/shift_parameter_mixup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ def _check_function(self, f: FunctionContract) -> List[Output]:
BinaryType.LEFT_SHIFT,
BinaryType.RIGHT_SHIFT,
]:
if isinstance(ir.variable_left, Constant):
if isinstance(ir.variable_left, Constant) and not isinstance(
ir.variable_right, Constant
):
info: DETECTOR_INFO = [
f,
" contains an incorrect shift operation: ",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
C.f() (tests/e2e/detectors/test_data/incorrect-shift/0.7.6/shift_parameter_mixup.sol#3-7) contains an incorrect shift operation: a = 8 >> a (tests/e2e/detectors/test_data/incorrect-shift/0.7.6/shift_parameter_mixup.sol#5)
C.f() (tests/e2e/detectors/test_data/incorrect-shift/0.7.6/shift_parameter_mixup.sol#3-8) contains an incorrect shift operation: a = 8 >> a (tests/e2e/detectors/test_data/incorrect-shift/0.7.6/shift_parameter_mixup.sol#5)

Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
contract C {

function f() internal returns (uint a) {
function f() internal returns (uint a, uint b) {
assembly {
a := shr(a, 8)
b := shl(248, 0xff)
}
}
}
Binary file not shown.

0 comments on commit c1ae06a

Please sign in to comment.