summaryrefslogtreecommitdiffhomepage
path: root/packet/bgp
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-04-05 22:25:51 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-04-05 22:25:51 +0900
commit4f000d78206a3ea926e616d6ea2b50f5d8b2e04c (patch)
treeb7a6e0abf65af9a7621f9a4dcd6402b38c19ad75 /packet/bgp
parentf6c909b6191012a88c499856b47272d826eba227 (diff)
packet: handle malformed option param length in OpenMessage
Fixes a possible crash in BGPOpen's DecodeFromBytes(). fixes #818 Signed-off-by: FUJITA Tomonori <fujita.tomonori@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 b7ee98cb..2de2af63 100644
--- a/packet/bgp/bgp.go
+++ b/packet/bgp/bgp.go
@@ -666,6 +666,9 @@ func (msg *BGPOpen) DecodeFromBytes(data []byte) error {
for rest := msg.OptParamLen; rest > 0; {
paramtype := data[0]
paramlen := data[1]
+ if rest < paramlen+2 {
+ return fmt.Errorf("Malformed BGP Open message")
+ }
rest -= paramlen + 2
if paramtype == BGP_OPT_CAPABILITY {