mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 05:36:46 +00:00
core/vm: undo change in actual run code
This commit is contained in:
parent
d456785bd4
commit
a53194ec37
1 changed files with 12 additions and 15 deletions
|
|
@ -598,27 +598,24 @@ func (c *bigModExp) RequiredGas(input []byte) uint64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *bigModExp) Run(input []byte) ([]byte, error) {
|
func (c *bigModExp) Run(input []byte) ([]byte, error) {
|
||||||
// Extract lengths - they're 32-byte big-endian integers
|
var (
|
||||||
// with the actual uint64 value in the last 8 bytes
|
baseLenBig = new(big.Int).SetBytes(getData(input, 0, 32))
|
||||||
var baseLen, expLen, modLen uint64
|
expLenBig = new(big.Int).SetBytes(getData(input, 32, 32))
|
||||||
if len(input) >= 32 {
|
modLenBig = new(big.Int).SetBytes(getData(input, 64, 32))
|
||||||
baseLen = binary.BigEndian.Uint64(input[24:32])
|
baseLen = baseLenBig.Uint64()
|
||||||
}
|
expLen = expLenBig.Uint64()
|
||||||
if len(input) >= 64 {
|
modLen = modLenBig.Uint64()
|
||||||
expLen = binary.BigEndian.Uint64(input[56:64])
|
inputLenOverflow = max(baseLenBig.BitLen(), expLenBig.BitLen(), modLenBig.BitLen()) > 64
|
||||||
}
|
)
|
||||||
if len(input) >= 96 {
|
|
||||||
modLen = binary.BigEndian.Uint64(input[88:96])
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(input) > 96 {
|
if len(input) > 96 {
|
||||||
input = input[96:]
|
input = input[96:]
|
||||||
} else {
|
} else {
|
||||||
input = input[:0]
|
input = input[:0]
|
||||||
}
|
}
|
||||||
|
|
||||||
// enforce size cap for inputs
|
// enforce size cap for inputs
|
||||||
if c.eip7823 && max(baseLen, expLen, modLen) > 1024 {
|
if c.eip7823 && (inputLenOverflow || max(baseLen, expLen, modLen) > 1024) {
|
||||||
return nil, fmt.Errorf("one or more of base/exponent/modulus length exceeded 1024 bytes")
|
return nil, errors.New("one or more of base/exponent/modulus length exceeded 1024 bytes")
|
||||||
}
|
}
|
||||||
// Handle a special case when both the base and mod length is zero
|
// Handle a special case when both the base and mod length is zero
|
||||||
if baseLen == 0 && modLen == 0 {
|
if baseLen == 0 && modLen == 0 {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue