UselessEthereumToken 合约漏洞

合约地址: https://etherscan.io/address/0x27f706edde3aD952EF647Dd67E24e38CD0803DD6#code
UselessEthereumToken 合约漏洞_第1张图片
问题点.png
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
        // mitigates the ERC20 short address attack
        if(msg.data.length < (3 * 32) + 4) { throw; }

        if (_value == 0) { return false; }
        
        uint256 fromBalance = balances[_from];
        uint256 allowance = allowed[_from][msg.sender];
        //问题所在,判断条件写反了
        bool sufficientFunds = fromBalance <= _value; //sufficientFunds = fromBalance >= _value;
        bool sufficientAllowance = allowance <= _value; //sufficientAllowance = allowance >= _value;
        bool overflowed = balances[_to] + _value > balances[_to];
        //正确写法 if (sufficientFunds && sufficientAllowance && overflowed) {
        if (sufficientFunds && sufficientAllowance && !overflowed) {
            balances[_to] += _value;
            balances[_from] -= _value;
            
            allowed[_from][msg.sender] -= _value;
            
            Transfer(_from, _to, _value);
            return true;
        } else { return false; }
    }
`

你可能感兴趣的:(UselessEthereumToken 合约漏洞)