From 4f23117d32c87cd5c5d6b7e3906ce83902e6e76f Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 29 Aug 2019 13:42:16 +0300 Subject: [PATCH] payload: fix wrong useragent parsing in version C# code reads is as a proper variable-length string, so it's not limited to 252 bytes. --- pkg/network/payload/version.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/pkg/network/payload/version.go b/pkg/network/payload/version.go index 35f97a40f..6545b19f5 100644 --- a/pkg/network/payload/version.go +++ b/pkg/network/payload/version.go @@ -60,11 +60,7 @@ func (p *Version) DecodeBinary(r io.Reader) error { br.ReadLE(&p.Timestamp) br.ReadLE(&p.Port) br.ReadLE(&p.Nonce) - - var lenUA uint8 - br.ReadLE(&lenUA) - p.UserAgent = make([]byte, lenUA) - br.ReadLE(&p.UserAgent) + p.UserAgent = br.ReadBytes() br.ReadLE(&p.StartHeight) br.ReadLE(&p.Relay) return br.Err @@ -79,8 +75,7 @@ func (p *Version) EncodeBinary(w io.Writer) error { br.WriteLE(p.Port) br.WriteLE(p.Nonce) - br.WriteLE(uint8(len(p.UserAgent))) - br.WriteLE(p.UserAgent) + br.WriteBytes(p.UserAgent) br.WriteLE(p.StartHeight) br.WriteLE(&p.Relay) return br.Err