Skip to content

Commit

Permalink
packet/bgp,mup: fix decode Interwork Segment Discovery route
Browse files Browse the repository at this point in the history
  • Loading branch information
higebu committed Jan 28, 2023
1 parent 033cfdb commit c61ef62
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pkg/packet/bgp/mup.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,8 @@ func (r *MUPInterworkSegmentDiscoveryRoute) DecodeFromBytes(data []byte, afi uin
if bits > addrLen*8 {
return NewMessageError(BGP_ERROR_UPDATE_MESSAGE_ERROR, BGP_ERROR_SUB_MALFORMED_ATTRIBUTE_LIST, nil, "prefix length is too long")
}
b := data[p:]
if addrLen > len(data[p:]) {
b = append(b, make([]byte, addrLen-len(data[p:]))...)
}
b := make([]byte, addrLen)
copy(b[0:byteLen], data[p:p+byteLen])
addr, ok := netip.AddrFromSlice(b)
if !ok {
return NewMessageError(BGP_ERROR_UPDATE_MESSAGE_ERROR, BGP_ERROR_SUB_MALFORMED_ATTRIBUTE_LIST, nil, fmt.Sprintf("Invalid Prefix: %x", data[p:]))
Expand Down

0 comments on commit c61ef62

Please sign in to comment.