From 89e404be46cfa30fdb994464a1c8e4fd93d3407f Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Wed, 20 Jan 2021 00:38:42 +0100 Subject: packet/bgp: Fix TunnelEncapSubTLV.DecodeFromBytes Return data of the correct length from TunnelEncapSubTLV.DecodeFromBytes. This fixes a problem with TunnelEncapSubTLVUnknown which caused it to contain more bytes in its Value unless it was the last SubTLV. Signed-off-by: Mikael Magnusson --- pkg/packet/bgp/bgp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/packet/bgp/bgp.go b/pkg/packet/bgp/bgp.go index 150c6c24..9add140f 100644 --- a/pkg/packet/bgp/bgp.go +++ b/pkg/packet/bgp/bgp.go @@ -11393,7 +11393,7 @@ func (t *TunnelEncapSubTLV) DecodeFromBytes(data []byte) (value []byte, err erro if len(data) < int(t.Length) { return nil, NewMessageError(BGP_ERROR_UPDATE_MESSAGE_ERROR, BGP_ERROR_SUB_MALFORMED_ATTRIBUTE_LIST, nil, "Not all TunnelEncapSubTLV bytes available") } - return data, nil + return data[:t.Length], nil } func (t *TunnelEncapSubTLV) Serialize(value []byte) (buf []byte, err error) { -- cgit v1.2.3