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 <[email protected]>
This commit is contained in:
Mikael Magnusson
2021-01-20 01:21:29 +01:00
parent 35e733246e
commit 89e404be46
+1 -1
View File
@@ -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) {