While attempting to peer with a vendor switch, parsing its
BGPOptParamCapabilityGracefulRestart excepted due to the length of the
identifier tuples not being a multiple of 4 octets.

It appears that this might be common as other implementations also stop
when the buffer is < 4.

Signed-off-by: Jason Kölker <[email protected]>
---
 ryu/lib/packet/bgp.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ryu/lib/packet/bgp.py b/ryu/lib/packet/bgp.py
index 66dbc3c..53bb174 100644
--- a/ryu/lib/packet/bgp.py
+++ b/ryu/lib/packet/bgp.py
@@ -1269,7 +1269,7 @@ class 
BGPOptParamCapabilityGracefulRestart(_OptParamCapability):
         (restart, ) = struct.unpack_from(cls._CAP_PACK_STR, 
six.binary_type(buf))
         buf = buf[2:]
         l = []
-        while len(buf) > 0:
+        while len(buf) >= 4:
             l.append(struct.unpack_from("!HBB", buf))
             buf = buf[4:]
         return {'flags': restart >> 12, 'time': restart & 0xfff, 'tuples': l}
-- 
2.5.0


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to