From f45c032eff7e72cf4fe5b04bec7603f2a844c846 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 7 Oct 2020 18:30:44 +0300 Subject: [PATCH] nef: limit the number of bytes to be read during decode --- pkg/smartcontract/nef/nef.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pkg/smartcontract/nef/nef.go b/pkg/smartcontract/nef/nef.go index 9725e3df4..39f6433bf 100644 --- a/pkg/smartcontract/nef/nef.go +++ b/pkg/smartcontract/nef/nef.go @@ -203,11 +203,7 @@ func (n *File) DecodeBinary(r *io.BinReader) { r.Err = errors.New("CRC verification fail") return } - n.Script = r.ReadVarBytes() - if len(n.Script) > MaxScriptLength { - r.Err = errors.New("invalid script length") - return - } + n.Script = r.ReadVarBytes(MaxScriptLength) if !hash.Hash160(n.Script).Equals(n.Header.ScriptHash) { r.Err = errors.New("script hashes mismatch") return