I was analyzing a contract in Oyente. The contract is :
pragma solidity ^0.4.21;
contract Test{
address admin;
function Test() public{
admin = msg.sender;
}
string str = "";
function setStr(string _str) public{
str = _str;
}
function getStr() public view returns (string){
return str;
}
}
When I passed this contract to oyente to analyze then the following report came:
INFO:root:contract Test.sol:Test:
INFO:symExec: ============ Results ===========
INFO:symExec: EVM Code Coverage: 24.1%
INFO:symExec: Integer Underflow: True
INFO:symExec: Integer Overflow: True
INFO:symExec: Parity Multisig Bug 2: False
INFO:symExec: Callstack Depth Attack Vulnerability: False
INFO:symExec: Transaction-Ordering Dependence (TOD): False
INFO:symExec: Timestamp Dependency: False
INFO:symExec: Re-Entrancy Vulnerability: False
INFO:symExec:Test.sol:16:9: Warning: Integer Underflow.
return str
Integer Underflow occurs if:
return str = 1
INFO:symExec:Test.sol:11:5: Warning: Integer Overflow.
function setStr(string _str) public{
^
Spanning multiple lines.
Integer Overflow occurs if:
_str = 115792089237316195423570985008687907853269984665640564039457584007913129639932
INFO:symExec: ====== Analysis Completed ======
It shows Integer overflow and underflow in a string variable. I really don't understand how it could happen or how to solve it. Any help will be appreciated.