Questions tagged [overflow]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
40 views

Solidity unsigned integer less than zero

I was trying to figure out the overflow in solidity, and I noticed that when I subtract one to a uint which was assigned by zero. The value will become ...
0
votes
1answer
40 views

Solidity array overflow

I'm trying to understand this array overflow attack on Solidity. (https://www.youtube.com/watch?v=gUqHgFuSsqg) In that video, the code is basically like this pragma solidity ^0.4.17; contract ...
0
votes
1answer
11 views

How is it possible to print tokens out of nowhere with the batchOverflow problem?

As stated in the title I've been looking at the Batch Overflow issue that happened last year where someone printed tokens out of nowhere. I see that when you create a token, you specify a totalSupply ...
0
votes
2answers
183 views

Integer overflow checking

In the code of Coin contract at: https://solidity.readthedocs.io/en/latest/introduction-to-smart-contracts.html#subcurrency-example there is the following function which requires the amount to be ...
1
vote
1answer
74 views

overflow/underflow issues?

pragma solidity 0.5.1; contract basics{ using SafeMath for *; uint time; address payable sender; uint amount; event moneySent(address s,uint a); mapping(address=>person) ...
1
vote
2answers
61 views

SafeMath and user input: it's always possible to overflow/underflow. No way out?

SafeMath doesn't prevent overflow/underflow from user input. Example: function sub(uint8 a, uint8 b) public returns(uint8) { require(b <= a); uint8 c = a - b; return c; } Say the user ...
0
votes
2answers
109 views

How overflows work in solidity?

I just finished the Token Level in Zeppelin's Ethernaut and in the end they explained that overflows are very common in solidity. I didn't even think about overflows, I just tried to steal the tokens. ...
2
votes
1answer
173 views

Problem with testing Integer Overflow

Good afternoon! I have a question regarding testing Integer overflows with truffle. The contract method is: function sumNumbers(uint256 numberA, uint256 numberB) public view returns(uint256) { ...
0
votes
1answer
36 views

Dealing with parameter overflow

Can parameter overflow be prevented in the contract, or does it have to be dealt with on the frontend? Solidity: contract parameterOverflows { uint8 selectedCharacter; modifier ...
1
vote
1answer
221 views

Truffle test: inputting an uint256 outputs a different result

To simplify my question, let's say I have a Test.sol with a function that simply output the input: function testFunc(uint256 value) public pure returns (uint256) { return value; } Now I want to ...
0
votes
2answers
46 views

what happens if you fill the maximum size of the index of an array

suppose I have an array with 2 ^ 256-1 elements What happens if I add another element?
3
votes
1answer
177 views

Balance overflow - ethereum sample token

Here is the first example token. pragma solidity ^0.4.20; contract MyToken { /* This creates an array with all balances */ mapping (address => uint256) public balanceOf; /* ...
4
votes
1answer
340 views

Why did the batchOverflow hack in the “BEC” contract work?

I am currently learning about how the current batch overflow happens. But there are some points I don't understand. The article says following: The vulnerable function is located in batchTransfer ...
5
votes
3answers
123 views

uint overflow problem:why not solve this problem in evm? [closed]

Solidity's uint256 can cause overflow. Why not resolve this problem in the EVM?
0
votes
2answers
382 views

Is overflow possible in this smart contract?

function mint(address beneficiary) public payable { uint256 MTCToken = (msg.value/10000) * (10 ** uint256(18)); uint256 teamToken = (MTCToken/100) * (5); balances[owner] += teamToken; ...
0
votes
2answers
289 views

How do I ensure that `1 << n` is executed as a 256-bit operation?

In other words, how do I ensure that 1 << n does not overflow for n < 256? At present, I am using uint256(1) << n. Is there a better way, or is it guaranteed that the expression ...
0
votes
1answer
397 views

SafeMath in ERC20 tokens: throw vs return false

On the one hand, protecting from over- and underflow is a must, and a widely used SafeMath library can help with that. SafeMath throws in case of error. On the other hand, ERC20 token functions are ...
1
vote
1answer
972 views

Issue with the Uint256

This is my first post here , I was not able to find the answer to my issue when I searched . I am using Remix with Metamask , I created the contract and using the following code to mint .I have a ...
1
vote
1answer
229 views

How does Ethereum/Solidity handle overflows in contracts?

Say I have a smart contract with variable of type uint256. I write a function to increment this variable. How does the EVM handle trying to increment the variable to store values beyond 256 bits? ...
1
vote
1answer
243 views

An underflow question

c: [ 11579208, 92373161954235, 70985008687907, 85326998466564, 5640394575840, 7913129639935 ] When I "underflow" a unchecked balance of coins, I get the array of ...
4
votes
3answers
2k views

SafeMath safe add function assertions against overflows

Looking at the following safeAdd function, which is common in many smart contracts out there, it seems that only a and c are compared. But can't it be that b will be the uint that will cause an ...
5
votes
1answer
1k views

How does uint types conversion works?

It seems (seemed) intuitive to me that there is no need to convert lower uints (e.g. uint8) to higher ones (uint256) within a formula. As I understood from the solidity docs it should be done ...
6
votes
1answer
748 views

How are solidity integer overflows handled?

uint8 x = 255; x += 10; Is x going to be 0 or 9?
16
votes
2answers
9k views

Is it possible to overflow uints?

The Ethereum token tutorial has a check for a uint256 overflow. function transfer(address _to, uint256 _value) { /* Check if sender has balance and for overflows */ if (balanceOf[msg.sender] ...