From 705941a80000dd2145a1629f701b0df04865ffab Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 7 Oct 2020 18:23:10 +0300 Subject: [PATCH] transaction: add script length limit As it is implemented in C# code. --- pkg/core/transaction/transaction.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/core/transaction/transaction.go b/pkg/core/transaction/transaction.go index 451b0b023..ff9f6973c 100644 --- a/pkg/core/transaction/transaction.go +++ b/pkg/core/transaction/transaction.go @@ -4,6 +4,7 @@ import ( "encoding/json" "errors" "fmt" + "math" "math/rand" "github.com/nspcc-dev/neo-go/pkg/config/netmode" @@ -14,6 +15,8 @@ import ( ) const ( + // MaxScriptLength is the limit for transaction's script length. + MaxScriptLength = math.MaxUint16 // MaxTransactionSize is the upper limit size in bytes that a transaction can reach. It is // set to be 102400. MaxTransactionSize = 102400 @@ -140,7 +143,7 @@ func (t *Transaction) decodeHashableFields(br *io.BinReader) { t.ValidUntilBlock = br.ReadU32LE() br.ReadArray(&t.Signers, MaxAttributes) br.ReadArray(&t.Attributes, MaxAttributes-len(t.Signers)) - t.Script = br.ReadVarBytes() + t.Script = br.ReadVarBytes(MaxScriptLength) if br.Err == nil { br.Err = t.isValid() }