payload: add a check for zero-length address list

Which is also present in C# code. Thanks, @AnnaShaleva.
This commit is contained in:
Roman Khimov 2020-10-08 13:26:18 +03:00
parent 5abec520c7
commit a44cb99df6
2 changed files with 30 additions and 6 deletions

View file

@ -80,6 +80,9 @@ func NewAddressList(n int) *AddressList {
// DecodeBinary implements Serializable interface.
func (p *AddressList) DecodeBinary(br *io.BinReader) {
br.ReadArray(&p.Addrs, MaxAddrsCount)
if len(p.Addrs) == 0 {
br.Err = errors.New("no addresses listed")
}
}
// EncodeBinary implements Serializable interface.