mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-07 05:07:36 +00:00
vm: limit POW, fix #2060
Calculating pow(pow(2, 255), 0xffffffff) takes unknown amount of time. See also neo-project/neo-vm#422.
This commit is contained in:
parent
2b7abd20e7
commit
15be763bb3
2 changed files with 2 additions and 3 deletions
|
@ -918,7 +918,7 @@ func (v *VM) execute(ctx *Context, op opcode.Opcode, parameter []byte) (err erro
|
|||
case opcode.POW:
|
||||
exp := v.estack.Pop().BigInt()
|
||||
a := v.estack.Pop().BigInt()
|
||||
if ei := exp.Int64(); !exp.IsInt64() || ei > math.MaxInt32 || ei < 0 {
|
||||
if ei := exp.Int64(); !exp.IsInt64() || ei > maxSHLArg || ei < 0 {
|
||||
panic("invalid exponent")
|
||||
}
|
||||
v.estack.PushVal(new(big.Int).Exp(a, exp, nil))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue