From d2bb2205de5f87b8d295a681eef393628147f688 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 18 Dec 2013 12:21:04 +0900 Subject: packet.ospf: workaround a bytearray vs buffer problem 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 Signed-off-by: FUJITA Tomonori --- 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 5c5a1799..f51ddf47 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 { -- cgit v1.2.3