mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-15 17:46:45 +02:00
packet lib: avoid exception for bogus protocol header parsing
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
6080f2c008
commit
df42ae87e8
@ -14,6 +14,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import inspect
|
||||
import struct
|
||||
|
||||
from . import packet_base
|
||||
from . import ethernet
|
||||
@ -47,11 +48,13 @@ class Packet(object):
|
||||
|
||||
def _parser(self, cls):
|
||||
while cls:
|
||||
proto, cls = cls.parser(self.data[self.parsed_bytes:])
|
||||
if proto:
|
||||
self.parsed_bytes += proto.length
|
||||
self.protocols.append(proto)
|
||||
|
||||
try:
|
||||
proto, cls = cls.parser(self.data[self.parsed_bytes:])
|
||||
if proto:
|
||||
self.parsed_bytes += proto.length
|
||||
self.protocols.append(proto)
|
||||
except struct.error:
|
||||
cls = None
|
||||
if len(self.data) > self.parsed_bytes:
|
||||
self.protocols.append(self.data[self.parsed_bytes:])
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user