diff options
-rw-r--r-- | packet/bgp/bgp.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/packet/bgp/bgp.go b/packet/bgp/bgp.go index 51453bb8..f89f547e 100644 --- a/packet/bgp/bgp.go +++ b/packet/bgp/bgp.go @@ -354,6 +354,9 @@ type CapGracefulRestart struct { func (c *CapGracefulRestart) DecodeFromBytes(data []byte) error { c.DefaultParameterCapability.DecodeFromBytes(data) data = data[2:] + if len(data) < 2 { + return NewMessageError(BGP_ERROR_OPEN_MESSAGE_ERROR, BGP_ERROR_SUB_UNSUPPORTED_CAPABILITY, nil, "Not all CapabilityGracefulRestart bytes available") + } restart := binary.BigEndian.Uint16(data[0:2]) c.Flags = uint8(restart >> 12) c.Time = restart & 0xfff |