mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
core: add overflow checks to IntrinsicGas
This commit is contained in:
parent
3f7b8bc976
commit
cdcc3b323d
1 changed files with 10 additions and 0 deletions
|
|
@ -107,10 +107,20 @@ func IntrinsicGas(data []byte, accessList types.AccessList, authList []types.Set
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if accessList != nil {
|
if accessList != nil {
|
||||||
|
if (math.MaxUint64-gas)/params.TxAccessListAddressGas < uint64(len(accessList)) {
|
||||||
|
return 0, ErrGasUintOverflow
|
||||||
|
}
|
||||||
gas += uint64(len(accessList)) * params.TxAccessListAddressGas
|
gas += uint64(len(accessList)) * params.TxAccessListAddressGas
|
||||||
|
|
||||||
|
if (math.MaxUint64-gas)/params.TxAccessListStorageKeyGas < uint64(accessList.StorageKeys()) {
|
||||||
|
return 0, ErrGasUintOverflow
|
||||||
|
}
|
||||||
gas += uint64(accessList.StorageKeys()) * params.TxAccessListStorageKeyGas
|
gas += uint64(accessList.StorageKeys()) * params.TxAccessListStorageKeyGas
|
||||||
}
|
}
|
||||||
if authList != nil {
|
if authList != nil {
|
||||||
|
if (math.MaxUint64-gas)/params.CallNewAccountGas < uint64(len(authList)) {
|
||||||
|
return 0, ErrGasUintOverflow
|
||||||
|
}
|
||||||
gas += uint64(len(authList)) * params.CallNewAccountGas
|
gas += uint64(len(authList)) * params.CallNewAccountGas
|
||||||
}
|
}
|
||||||
return gas, nil
|
return gas, nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue