diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-08-15 15:31:29 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-15 15:31:29 +0800 |
commit | 9facf6423dbd38ebd7fbd9069cbcb98b0fd243c2 (patch) | |
tree | c3dbd1b33acc3f57ecdc43acd707d511a6191104 /core/vm/common.go | |
parent | 2403656373f1250e3668227bd9fc94e6e95412b9 (diff) | |
parent | f8d8b56b280dd921436fb046dbcaa010ef43122d (diff) | |
download | dexon-9facf6423dbd38ebd7fbd9069cbcb98b0fd243c2.tar dexon-9facf6423dbd38ebd7fbd9069cbcb98b0fd243c2.tar.gz dexon-9facf6423dbd38ebd7fbd9069cbcb98b0fd243c2.tar.bz2 dexon-9facf6423dbd38ebd7fbd9069cbcb98b0fd243c2.tar.lz dexon-9facf6423dbd38ebd7fbd9069cbcb98b0fd243c2.tar.xz dexon-9facf6423dbd38ebd7fbd9069cbcb98b0fd243c2.tar.zst dexon-9facf6423dbd38ebd7fbd9069cbcb98b0fd243c2.zip |
Merge pull request #14959 from karalabe/metropolis-precompiles
core/vm: metropolis precompiles
Diffstat (limited to 'core/vm/common.go')
-rw-r--r-- | core/vm/common.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/core/vm/common.go b/core/vm/common.go index 779cee006..17de38dec 100644 --- a/core/vm/common.go +++ b/core/vm/common.go @@ -34,7 +34,21 @@ func calcMemSize(off, l *big.Int) *big.Int { // getData returns a slice from the data based on the start and size and pads // up to size with zero's. This function is overflow safe. -func getData(data []byte, start, size *big.Int) []byte { +func getData(data []byte, start uint64, size uint64) []byte { + length := uint64(len(data)) + if start > length { + start = length + } + end := start + size + if end > length { + end = length + } + return common.RightPadBytes(data[start:end], int(size)) +} + +// getDataBig returns a slice from the data based on the start and size and pads +// up to size with zero's. This function is overflow safe. +func getDataBig(data []byte, start *big.Int, size *big.Int) []byte { dlen := big.NewInt(int64(len(data))) s := math.BigMin(start, dlen) |