feeding bytearray to struct.unpack() crashes on some environment.
(depends on the interpreter versions?  i'm not sure.)

this fixes the following crash in the unit test.
the crash was seen on travis-ci, too.
https://travis-ci.org/osrg/ryu/jobs/15578909
https://s3.amazonaws.com/archive.travis-ci.org/jobs/15578909/log.txt

======================================================================
ERROR: test_hello (packet.test_ospf.Test_ospf)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/yamamoto/git/ryu/ryu/tests/unit/packet/test_ospf.py", line 68, 
in test_hello
    msg2, cls, rest = ospf.OSPFMessage.parser(binmsg)
  File "/Users/yamamoto/git/ryu/ryu/lib/packet/ospf.py", line 443, in parser
    kwargs = subcls.parser(binmsg)
  File "/Users/yamamoto/git/ryu/ryu/lib/packet/ospf.py", line 501, in parser
    n = addrconv.ipv4.bin_to_text(n)
  File "/Users/yamamoto/git/ryu/ryu/lib/addrconv.py", line 30, in bin_to_text
    return str(self._addr(self._strat.packed_to_int(bin),
  File 
"/Users/yamamoto/git/ryu/.venv/lib/python2.7/site-packages/netaddr/strategy/ipv4.py",
 line 196, in packed_to_int
    return _struct.unpack('>I', packed_int)[0]
error: unpack requires a string argument of length 4

----------------------------------------------------------------------

Signed-off-by: YAMAMOTO Takashi <[email protected]>
---
 ryu/lib/packet/ospf.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ryu/lib/packet/ospf.py b/ryu/lib/packet/ospf.py
index 5c5a179..f51ddf4 100644
--- a/ryu/lib/packet/ospf.py
+++ b/ryu/lib/packet/ospf.py
@@ -498,7 +498,7 @@ class OSPFHello(OSPFMessage):
         binneighbors = buf[cls._PACK_LEN:len(buf)]
         while binneighbors:
             n = binneighbors[:4]
-            n = addrconv.ipv4.bin_to_text(n)
+            n = addrconv.ipv4.bin_to_text(buffer(n))
             binneighbors = binneighbors[4:]
             neighbors.append(n)
         return {
-- 
1.8.3.4 (Apple Git-47)


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to