diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-05-26 07:51:10 +0000 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-05-26 17:13:23 +0900 |
commit | 1e47e4f6674b8156fed6efa602166d155c7734f7 (patch) | |
tree | ed0000fc500869051ffbbaaedf7c3e38d5a00e48 /packet | |
parent | 00b5ca442e9622cd5c643c8a62860c9499ccf1ac (diff) |
bgp: check buf length before parsing graceful-restart capability
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'packet')
-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 |