summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYAMAMOTO Takashi <yamamoto@valinux.co.jp>2013-12-18 12:21:04 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2013-12-18 13:10:07 +0900
commitd2bb2205de5f87b8d295a681eef393628147f688 (patch)
tree3f1719bcefb4c2753530ec926e844759d593d312
parent5ac517ab36614d737c6434d9150ad0f68ecc694e (diff)
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 <yamamoto@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/lib/packet/ospf.py2
1 files changed, 1 insertions, 1 deletions
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 {