diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2016-09-27 14:25:21 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-10-01 21:37:58 +0900 |
commit | 35973fcc20ad4e55d1a9a527266d02baebdb9dca (patch) | |
tree | 83f9fb5f3d487db41b459513be57a40370f0a00e | |
parent | 51e0abd3659efeaa0fd331b4af614e6b655c2a0d (diff) |
packet: Avoid parsing an empty buffer
For example, the packet library detects the TCP payload type by using
the TCP src/dst port, but in case of the BGP packet, the packet
library will try to parse a TCP ACK packet as a BGP packet, and will
fail to parse.
This patch enables to ignore an empty buffer and fixes this problem.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/lib/packet/packet.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/ryu/lib/packet/packet.py b/ryu/lib/packet/packet.py index 043dae75..7de24c18 100644 --- a/ryu/lib/packet/packet.py +++ b/ryu/lib/packet/packet.py @@ -69,6 +69,9 @@ class Packet(StringifyMixin): def _parser(self, cls): rest_data = self.data while cls: + # Ignores an empty buffer + if not six.binary_type(rest_data).strip(b'\x00'): + break try: proto, cls, rest_data = cls.parser(rest_data) except struct.error: |