summaryrefslogtreecommitdiffhomepage
path: root/packet/bgp.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-25 23:47:14 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-25 23:47:14 +0900
commit5443db3093965ce5f137f7fc9d9018723c20c400 (patch)
tree2157d3afdf98d997e27406b67eea618f8a40f4ba /packet/bgp.go
parent7ed648411a611ba1e90691c44d270acfc81302e8 (diff)
packet: check Header.Len
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'packet/bgp.go')
-rw-r--r--packet/bgp.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/packet/bgp.go b/packet/bgp.go
index 17fcabef..5131a284 100644
--- a/packet/bgp.go
+++ b/packet/bgp.go
@@ -2613,10 +2613,13 @@ type BGPHeader struct {
func (msg *BGPHeader) DecodeFromBytes(data []byte) error {
// minimum BGP message length
- if uint16(len(data)) < 19 {
+ if uint16(len(data)) < BGP_HEADER_LENGTH {
return fmt.Errorf("Not all BGP message header")
}
msg.Len = binary.BigEndian.Uint16(data[16:18])
+ if int(msg.Len) < BGP_HEADER_LENGTH {
+ return NewMessageError(BGP_ERROR_MESSAGE_HEADER_ERROR, BGP_ERROR_SUB_BAD_MESSAGE_LENGTH, nil, "unknown message type")
+ }
msg.Type = data[18]
return nil
}