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.
This commit is contained in:
Roman Khimov 2019-08-29 13:42:16 +03:00
parent 7b46f9bb86
commit 4f23117d32

View file

@ -60,11 +60,7 @@ func (p *Version) DecodeBinary(r io.Reader) error {
br.ReadLE(&p.Timestamp) br.ReadLE(&p.Timestamp)
br.ReadLE(&p.Port) br.ReadLE(&p.Port)
br.ReadLE(&p.Nonce) br.ReadLE(&p.Nonce)
p.UserAgent = br.ReadBytes()
var lenUA uint8
br.ReadLE(&lenUA)
p.UserAgent = make([]byte, lenUA)
br.ReadLE(&p.UserAgent)
br.ReadLE(&p.StartHeight) br.ReadLE(&p.StartHeight)
br.ReadLE(&p.Relay) br.ReadLE(&p.Relay)
return br.Err return br.Err
@ -79,8 +75,7 @@ func (p *Version) EncodeBinary(w io.Writer) error {
br.WriteLE(p.Port) br.WriteLE(p.Port)
br.WriteLE(p.Nonce) br.WriteLE(p.Nonce)
br.WriteLE(uint8(len(p.UserAgent))) br.WriteBytes(p.UserAgent)
br.WriteLE(p.UserAgent)
br.WriteLE(p.StartHeight) br.WriteLE(p.StartHeight)
br.WriteLE(&p.Relay) br.WriteLE(&p.Relay)
return br.Err return br.Err