summaryrefslogtreecommitdiffhomepage
path: root/packet/bgp
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-05-26 07:51:10 +0000
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-05-26 17:13:23 +0900
commit1e47e4f6674b8156fed6efa602166d155c7734f7 (patch)
treeed0000fc500869051ffbbaaedf7c3e38d5a00e48 /packet/bgp
parent00b5ca442e9622cd5c643c8a62860c9499ccf1ac (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/bgp')
-rw-r--r--packet/bgp/bgp.go3
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