Skip to content

Commit

Permalink
overflow check when calculating the position (#103)
Browse files Browse the repository at this point in the history
* overflow check when calculating the position

* less than or equal to
  • Loading branch information
hamdiallam authored Feb 26, 2019
1 parent 51f51e6 commit 2a41203
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion contracts/PlasmaMVP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,10 @@ contract PlasmaMVP {
{
require(validatePostion([txPos[0], txPos[1], txPos[2], 0]));

return txPos[0].mul(blockIndexFactor).add(txPos[1].mul(txIndexFactor)).add(txPos[2]);
uint256 position = txPos[0].mul(blockIndexFactor).add(txPos[1].mul(txIndexFactor)).add(txPos[2]);
require(position <= 2**128-1); // check for an overflow

return position;
}

function validatePostion(uint256[4] memory position)
Expand Down

0 comments on commit 2a41203

Please sign in to comment.