diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-02-16 10:52:55 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-02-16 10:52:55 +0900 |
commit | d7253516a40801c7dcca553ffe244ccb0994116e (patch) | |
tree | c2649a7f27cb023fb6e7f11b10844399ff9a6da6 /packet/bgp.go | |
parent | 560fa6cbd5c6ddb8fcd5c262b720459c064a9b23 (diff) |
server: check the bgp message length before sending
if the length is over 4096, the message will be dropped.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'packet/bgp.go')
-rw-r--r-- | packet/bgp.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/packet/bgp.go b/packet/bgp.go index aa76cb12..79f62978 100644 --- a/packet/bgp.go +++ b/packet/bgp.go @@ -2734,6 +2734,9 @@ func (msg *BGPMessage) Serialize() ([]byte, error) { return nil, err } if msg.Header.Len == 0 { + if 19 + len(b) > BGP_MAX_MESSAGE_LENGTH { + return nil, NewMessageError(0, 0, nil, fmt.Sprintf("too long message length %d", 19 + len(b))) + } msg.Header.Len = 19 + uint16(len(b)) } h, err := msg.Header.Serialize() |