From 0ac9ac9b2561dceb430e96b2a7973a1a05ab61a0 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Wed, 21 Oct 2020 09:18:22 +0900 Subject: packet: handle malformed prefix len Signed-off-by: FUJITA Tomonori --- pkg/packet/bgp/bgp_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'pkg/packet/bgp/bgp_test.go') diff --git a/pkg/packet/bgp/bgp_test.go b/pkg/packet/bgp/bgp_test.go index 2f4b4588..d821d072 100644 --- a/pkg/packet/bgp/bgp_test.go +++ b/pkg/packet/bgp/bgp_test.go @@ -84,6 +84,12 @@ func Test_IPAddrPrefixString(t *testing.T) { assert.Equal(t, "3343:faba:3903:128::/63", ipv6.String()) } +func Test_IPAddrDecode(t *testing.T) { + r := IPAddrPrefixDefault{} + b := make([]byte, 16) + r.decodePrefix(b, 33, 4) +} + func Test_RouteTargetMembershipNLRIString(t *testing.T) { assert := assert.New(t) @@ -667,7 +673,7 @@ func Test_AddPath(t *testing.T) { n1.SetPathLocalIdentifier(20) bits, err := n1.Serialize(opt) assert.Nil(err) - n2 := NewLabeledVPNIPAddrPrefix(0, "", MPLSLabelStack{}, nil) + n2 := NewLabeledVPNIPv6AddrPrefix(0, "", MPLSLabelStack{}, nil) err = n2.DecodeFromBytes(bits, opt) assert.Nil(err) assert.Equal(n2.PathIdentifier(), uint32(20)) @@ -690,7 +696,7 @@ func Test_AddPath(t *testing.T) { n1.SetPathLocalIdentifier(20) bits, err := n1.Serialize(opt) assert.Nil(err) - n2 := NewLabeledIPAddrPrefix(0, "", MPLSLabelStack{}) + n2 := NewLabeledIPv6AddrPrefix(0, "", MPLSLabelStack{}) err = n2.DecodeFromBytes(bits, opt) assert.Nil(err) assert.Equal(n2.PathIdentifier(), uint32(20)) -- cgit v1.2.3