From f318e573d4a65f7c2b80d81beeceba8b86dd996a Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 7 Oct 2020 18:27:24 +0300 Subject: [PATCH] payload: limit the user agent field in version payload Protocol limit. --- pkg/network/payload/version.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/network/payload/version.go b/pkg/network/payload/version.go index 6bb3bcdc1..dee8650a1 100644 --- a/pkg/network/payload/version.go +++ b/pkg/network/payload/version.go @@ -8,6 +8,9 @@ import ( "github.com/nspcc-dev/neo-go/pkg/network/capability" ) +// MaxUserAgentLength is the limit for user agent field. +const MaxUserAgentLength = 1024 + // Version payload. type Version struct { // NetMode of the node @@ -42,7 +45,7 @@ func (p *Version) DecodeBinary(br *io.BinReader) { p.Version = br.ReadU32LE() p.Timestamp = br.ReadU32LE() p.Nonce = br.ReadU32LE() - p.UserAgent = br.ReadVarBytes() + p.UserAgent = br.ReadVarBytes(MaxUserAgentLength) p.Capabilities.DecodeBinary(br) }