From 8424ff0e9132785f7ba7ff55e29b761ec6687f4b Mon Sep 17 00:00:00 2001
From: Daniel Czerwonk <daniel@dan-nrw.de>
Date: Sat, 21 Jul 2018 11:02:38 +0200
Subject: [PATCH] added test for existing boundary check

---
 protocols/bgp/packet/path_attributes_test.go | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/protocols/bgp/packet/path_attributes_test.go b/protocols/bgp/packet/path_attributes_test.go
index 606ee24c..14ce9c20 100644
--- a/protocols/bgp/packet/path_attributes_test.go
+++ b/protocols/bgp/packet/path_attributes_test.go
@@ -968,6 +968,17 @@ func TestDecodeMultiProtocolReachNLRI(t *testing.T) {
 				},
 			},
 		},
+		{
+			name: "MP_REACH_NLRI with invalid prefixes",
+			input: []byte{
+				0x00, 0x02, // AFI
+				0x01,                                                                                                 // SAFI
+				0x10, 0x20, 0x01, 0x06, 0x78, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, // NextHop
+				0x00,             // RESERVED
+				0x30, 0x26, 0x00, // Prefix
+			},
+			wantFail: true,
+		},
 	}
 
 	t.Parallel()
@@ -1039,6 +1050,15 @@ func TestDecodeMultiProtocolUnreachNLRI(t *testing.T) {
 			},
 			wantFail: true,
 		},
+		{
+			name: "MP_REACH_NLRI with invalid prefixes",
+			input: []byte{
+				0x00, 0x02, // AFI
+				0x01,                   // SAFI
+				0x2c, 0x26, 0x20, 0x01, // Prefix
+			},
+			wantFail: true,
+		},
 	}
 
 	t.Parallel()
-- 
GitLab