summaryrefslogtreecommitdiffhomepage
path: root/pkg/packet/bgp/sr_policy.go
diff options
context:
space:
mode:
authorSergey Elantsev <elantsev.s@yandex.ru>2020-12-20 18:13:10 +0300
committerSergey Elantsev <elantsev.s@yandex.ru>2020-12-20 18:13:10 +0300
commit0558066261625d0f4e7d5c118a0efd4238d24715 (patch)
treec525c80171c1664d6f5f6cdab0eef36d3874d4ed /pkg/packet/bgp/sr_policy.go
parent5aa7108d85b6926eca99978a2fb0e728176aae98 (diff)
fixed possible crashes on parsing of bgp messages
Diffstat (limited to 'pkg/packet/bgp/sr_policy.go')
-rw-r--r--pkg/packet/bgp/sr_policy.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/pkg/packet/bgp/sr_policy.go b/pkg/packet/bgp/sr_policy.go
index e7baa069..cdd89db2 100644
--- a/pkg/packet/bgp/sr_policy.go
+++ b/pkg/packet/bgp/sr_policy.go
@@ -742,9 +742,12 @@ func (t *TunnelEncapSubTLVSRSegmentList) DecodeFromBytes(data []byte) error {
if err != nil {
return NewMessageError(BGP_ERROR_UPDATE_MESSAGE_ERROR, BGP_ERROR_SUB_MALFORMED_ATTRIBUTE_LIST, nil, err.Error())
}
+ if len(value) < 1 {
+ return NewMessageError(BGP_ERROR_MESSAGE_HEADER_ERROR, BGP_ERROR_SUB_BAD_MESSAGE_LENGTH, nil, "Malformed BGP message")
+ }
// Skip reserved byte to access inner SubTLV type
value = value[1:]
- segments := make([]TunnelEncapSubTLVInterface, 0)
+ var segments []TunnelEncapSubTLVInterface
p := 0
for p < t.TunnelEncapSubTLV.Len()-4 {
var segment TunnelEncapSubTLVInterface