-
Notifications
You must be signed in to change notification settings - Fork 20.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core/vm: metropolis precompiles #14959
Changes from all commits
7bbdf3e
6131dd5
d8aaa3a
f8d8b56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Though, I guess it would be overflow safe if you ensured that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, if start + size can overflow a uint64, the big version of this method should be used. |
||
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) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment says
this function is overflow safe
. It's not..There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overflow safe as in you can index outside of the bounds.