Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
]
},
"expect": {
"out": []
"status": "10",
"message": "str:bad bounds"
}
},
{
Expand Down Expand Up @@ -97,7 +98,8 @@
]
},
"expect": {
"out": []
"status": "10",
"message": "str:bad bounds"
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
},
"expect": {
"out": [],
"status": "4",
"message": "str:argument decode error (s): input too short",
"status": "10",
"message": "str:bad bounds",
"logs": "*",
"gas": "*",
"refund": "*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
]
},
"expect": {
"out": []
"status": "10",
"message": "str:bad bounds"
}
},
{
Expand Down Expand Up @@ -97,7 +98,8 @@
]
},
"expect": {
"out": []
"status": "10",
"message": "str:bad bounds"
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,8 @@
]
},
"expect": {
"out": [
"u8:1|u8:2|u8:3"
],
"status": "",
"logs": "*"
"status": "10",
"message": "str:bad bounds"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,8 @@
]
},
"expect": {
"out": [
"0",
"0",
"false",
"",
"",
"",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"",
""
],
"status": "0"
"status": "10",
"message": "str:bad bounds"
}
},
{
Expand All @@ -206,18 +196,8 @@
]
},
"expect": {
"out": [
"0",
"0",
"false",
"",
"",
"",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"",
""
],
"status": "0"
"status": "10",
"message": "str:bad bounds"
}
},
{
Expand All @@ -233,18 +213,8 @@
]
},
"expect": {
"out": [
"1",
"0",
"false",
"",
"",
"",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"",
""
],
"status": "0"
"status": "10",
"message": "str:bad bounds"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
"gasPrice": "0"
},
"expect": {
"out": [],
"status": "0",
"status": "10",
"message": "str:bad bounds",
"gas": "*",
"refund": "*"
}
Expand Down Expand Up @@ -98,19 +98,9 @@
{
"nonce": "1",
"balance": "1"
},
{
"nonce": "2",
"balance": "1",
"creator": "sc:forwarder",
"royalties": "0",
"hash": "str:nft-create-hash-----------------",
"uri": [
"str:nft-create-uri"
]
}
],
"lastNonce": "2",
"lastNonce": "1",
"roles": [
"ESDTRoleNFTCreate"
]
Expand Down
8 changes: 7 additions & 1 deletion vmhost/contexts/managedType.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,13 @@ func (context *managedTypesContext) GetSlice(mBufferHandle int32, startPosition
if !ok {
return nil, vmhost.ErrNoManagedBufferUnderThisHandle
}
if int(lengthOfSlice) > len(mBuffer)-int(startPosition) || lengthOfSlice < 0 || startPosition < 0 {
if startPosition < 0 || lengthOfSlice < 0 {
return nil, vmhost.ErrBadBounds
}
if len(mBuffer) < int(startPosition) {
return nil, vmhost.ErrBadBounds
}
if len(mBuffer)-int(startPosition) < int(lengthOfSlice) {
return nil, vmhost.ErrBadBounds
}
return mBuffer[startPosition:(startPosition + lengthOfSlice)], nil
Expand Down
6 changes: 0 additions & 6 deletions vmhost/hostCore/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -690,12 +690,6 @@ func (host *vmHost) CreateNewContract(input *vmcommon.ContractCreateInput, creat
newContractAddress = nil
err = nil

defer func() {
if err != nil {
newContractAddress = nil
}
}()

_, blockchain, metering, output, runtime, _, _ := host.GetContexts()

codeDeployInput := vmhost.CodeDeployInput{
Expand Down
8 changes: 4 additions & 4 deletions vmhost/hosttest/execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1081,10 +1081,10 @@ func TestExecution_ManagedBuffers_SetByteSlice(t *testing.T) {
runTestMBufferSetByteSlice(t, true, 0, 26, vmcommon.Ok, []byte("ABCDEFGHIJKLMNOPQRSTUVWXYZ"))

// Bounds exceeded, source remains unchanged lowercase.
runTestMBufferSetByteSlice(t, true, 18, 9, vmcommon.Ok, []byte("abcdefghijklmnopqrstuvwxyz"))
runTestMBufferSetByteSlice(t, true, -1, 2, vmcommon.Ok, []byte("abcdefghijklmnopqrstuvwxyz"))
runTestMBufferSetByteSlice(t, true, 25, 2, vmcommon.Ok, []byte("abcdefghijklmnopqrstuvwxyz"))
runTestMBufferSetByteSlice(t, true, 0, 27, vmcommon.Ok, []byte("abcdefghijklmnopqrstuvwxyz"))
runTestMBufferSetByteSlice(t, true, 18, 9, vmcommon.ExecutionFailed, nil)
runTestMBufferSetByteSlice(t, true, -1, 2, vmcommon.ExecutionFailed, nil)
runTestMBufferSetByteSlice(t, true, 25, 2, vmcommon.ExecutionFailed, nil)
runTestMBufferSetByteSlice(t, true, 0, 27, vmcommon.ExecutionFailed, nil)
}

func runTestMBufferSetByteSliceDeploy(t *testing.T, enabled bool, retCode vmcommon.ReturnCode) {
Expand Down
2 changes: 2 additions & 0 deletions vmhost/vmhooks/bigIntOps.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func (context *VMHooksImpl) BigIntGetUnsignedArgument(id int32, destinationHandl

args := runtime.Arguments()
if int32(len(args)) <= id || id < 0 {
context.FailExecution(vmhost.ErrArgIndexOutOfRange)
return
}

Expand All @@ -95,6 +96,7 @@ func (context *VMHooksImpl) BigIntGetSignedArgument(id int32, destinationHandle

args := runtime.Arguments()
if int32(len(args)) <= id || id < 0 {
context.FailExecution(vmhost.ErrArgIndexOutOfRange)
return
}

Expand Down
12 changes: 9 additions & 3 deletions vmhost/vmhooks/manBufOps.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package vmhooks

import (
"bytes"
"fmt"
"math/big"
"strings"

Expand Down Expand Up @@ -164,7 +165,7 @@ func (context *VMHooksImpl) MBufferGetByteSlice(
}

if startingPosition < 0 || sliceLength < 0 || int(startingPosition+sliceLength) > len(sourceBytes) {
// does not fail execution if slice exceeds bounds
context.FailExecution(vmhost.ErrBadBounds)
return 1
}

Expand Down Expand Up @@ -210,7 +211,7 @@ func ManagedBufferCopyByteSliceWithHost(host vmhost.VMHost, sourceHandle int32,
}

if startingPosition < 0 || sliceLength < 0 || int(startingPosition+sliceLength) > len(sourceBytes) {
// does not fail execution if slice exceeds bounds
FailExecution(host, vmhost.ErrBadBounds)
return 1
}

Expand Down Expand Up @@ -359,7 +360,7 @@ func ManagedBufferSetByteSliceWithTypedArgs(host vmhost.VMHost, mBufferHandle in
}

if startingPosition < 0 || dataLength < 0 || int(startingPosition+dataLength) > len(bufferBytes) {
// does not fail execution if slice exceeds bounds
FailExecution(host, vmhost.ErrBadBounds)
return 1
}

Expand Down Expand Up @@ -703,6 +704,11 @@ func (context *VMHooksImpl) MBufferToBigFloat(mBufferHandle, bigFloatHandle int3
}

bigFloat := new(big.Float)
defer func() {
if r := recover(); r != nil {
context.FailExecution(fmt.Errorf("panic in GobDecode: %v", r))
}
}()
err = bigFloat.GobDecode(managedBuffer)
if err != nil {
if !enableEpochsHandler.IsFlagEnabled(vmhost.ValidationOnGobDecodeFlag) &&
Expand Down
Loading