mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
fix(modexp): disallow len of 0x8000000000000000000000000000000000000000000… (#496)
* modexp: disallow len of 0x8000000000000000000000000000000000000000000000000000000000000000 * minor --------- Co-authored-by: HAOYUatHZ <haoyu@protonmail.com>
This commit is contained in:
parent
63cbb77cdc
commit
ef328dbb6e
2 changed files with 11 additions and 5 deletions
|
|
@ -407,12 +407,18 @@ func (c *bigModExp) RequiredGas(input []byte) uint64 {
|
|||
|
||||
func (c *bigModExp) Run(input []byte) ([]byte, error) {
|
||||
var (
|
||||
baseLen = new(big.Int).SetBytes(getData(input, 0, 32)).Uint64()
|
||||
expLen = new(big.Int).SetBytes(getData(input, 32, 32)).Uint64()
|
||||
modLen = new(big.Int).SetBytes(getData(input, 64, 32)).Uint64()
|
||||
baseLenBigInt = new(big.Int).SetBytes(getData(input, 0, 32))
|
||||
expLenBigInt = new(big.Int).SetBytes(getData(input, 32, 32))
|
||||
modLenBigInt = new(big.Int).SetBytes(getData(input, 64, 32))
|
||||
)
|
||||
var (
|
||||
baseLen = baseLenBigInt.Uint64()
|
||||
expLen = expLenBigInt.Uint64()
|
||||
modLen = modLenBigInt.Uint64()
|
||||
)
|
||||
// Check that all inputs are `u256` (32 - bytes) or less, revert otherwise
|
||||
if baseLen > 32 || expLen > 32 || modLen > 32 {
|
||||
var lenLimit = new(big.Int).SetInt64(32)
|
||||
if baseLenBigInt.Cmp(lenLimit) > 0 || expLenBigInt.Cmp(lenLimit) > 0 || modLenBigInt.Cmp(lenLimit) > 0 {
|
||||
return nil, errModexpUnsupportedInput
|
||||
}
|
||||
if len(input) > 96 {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import (
|
|||
const (
|
||||
VersionMajor = 4 // Major version component of the current release
|
||||
VersionMinor = 3 // Minor version component of the current release
|
||||
VersionPatch = 57 // Patch version component of the current release
|
||||
VersionPatch = 58 // Patch version component of the current release
|
||||
VersionMeta = "sepolia" // Version metadata to append to the version string
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue