FunC does not respect error code 5 in left shift and right shift operators #2997
Labels
activity: found-by-fuzzing
Do not add! Issues found by fuzzer by previous project.
misc: func-bug
Bugs in FunC compiler
In the following contract that uses right and left shifts:
Getters
getBool1
andgetBool2
will returntrue
for any assignment of parameterx
outside the interval[0..256]
. However, the expected behavior is to produce error code5
when calling such getters outside the allowed interval[0..256]
. The interpreter does report an error; for example, interpreting(-1 >> x) <= 1
whenx = -2
produces the error:Cannot evaluate expression to a constant: the number of bits shifted ('-2') must be within [0..256] range
.The FunC code of the above getters is:
While the Fift code of the above getters is:
Notice that FunC replaced the expressions
(-1 >> $x) <= 1
and(-1 << $x) <= 1
withTRUE
in the Fift code.The above means that it is not safe to rely on catching error code 5 in
try/catch
statements in order to execute important business logic, similar to issue #2832 for integer overflows.The text was updated successfully, but these errors were encountered: