mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-05 03:06:16 +00:00
vm: restrict max invocation stack size
This commit is contained in:
parent
0ea7568caa
commit
c7f0b7bd68
2 changed files with 42 additions and 2 deletions
|
@ -197,6 +197,27 @@ func TestPushData4Good(t *testing.T) {
|
|||
assert.Equal(t, []byte{1, 2, 3}, vm.estack.Pop().Bytes())
|
||||
}
|
||||
|
||||
func callNTimes(n uint16) []byte {
|
||||
return makeProgram(
|
||||
PUSHBYTES2, Instruction(n), Instruction(n>>8), // little-endian
|
||||
TOALTSTACK, DUPFROMALTSTACK,
|
||||
JMPIF, 0x4, 0, RET,
|
||||
FROMALTSTACK, DEC,
|
||||
CALL, 0xF8, 0xFF) // -8 -> JMP to TOALTSTACK)
|
||||
}
|
||||
|
||||
func TestInvocationLimitGood(t *testing.T) {
|
||||
prog := callNTimes(MaxInvocationStackSize - 1)
|
||||
v := load(prog)
|
||||
runVM(t, v)
|
||||
}
|
||||
|
||||
func TestInvocationLimitBad(t *testing.T) {
|
||||
prog := callNTimes(MaxInvocationStackSize)
|
||||
v := load(prog)
|
||||
checkVMFailed(t, v)
|
||||
}
|
||||
|
||||
func TestNOTNoArgument(t *testing.T) {
|
||||
prog := makeProgram(NOT)
|
||||
vm := load(prog)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue