Skip to content

Commit c61ef62

Browse files
committed
packet/bgp,mup: fix decode Interwork Segment Discovery route
1 parent 033cfdb commit c61ef62

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

pkg/packet/bgp/mup.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,8 @@ func (r *MUPInterworkSegmentDiscoveryRoute) DecodeFromBytes(data []byte, afi uin
292292
if bits > addrLen*8 {
293293
return NewMessageError(BGP_ERROR_UPDATE_MESSAGE_ERROR, BGP_ERROR_SUB_MALFORMED_ATTRIBUTE_LIST, nil, "prefix length is too long")
294294
}
295-
b := data[p:]
296-
if addrLen > len(data[p:]) {
297-
b = append(b, make([]byte, addrLen-len(data[p:]))...)
298-
}
295+
b := make([]byte, addrLen)
296+
copy(b[0:byteLen], data[p:p+byteLen])
299297
addr, ok := netip.AddrFromSlice(b)
300298
if !ok {
301299
return NewMessageError(BGP_ERROR_UPDATE_MESSAGE_ERROR, BGP_ERROR_SUB_MALFORMED_ATTRIBUTE_LIST, nil, fmt.Sprintf("Invalid Prefix: %x", data[p:]))

0 commit comments

Comments
 (0)