Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packet out message with no data causes crash #10

Open
KitL opened this issue Nov 10, 2017 · 0 comments
Open

Packet out message with no data causes crash #10

KitL opened this issue Nov 10, 2017 · 0 comments

Comments

@KitL
Copy link

KitL commented Nov 10, 2017

Hi,

I hit a problem with packet out messages when they are used to output buffered packets. When you do this you send a packet out message with a buffer_id != -1 and no data. But you still try to unpack the empty data field.

Traceback (most recent call last):
  File "ofp_sniffer.py", line 234, in <module>
    main()
  File "ofp_sniffer.py", line 222, in main
    sniffer.run()
  File "ofp_sniffer.py", line 90, in run
    self.cap.loop(-1, self.process_packet)
  File "ofp_sniffer.py", line 161, in process_packet
    self.ofp_proxy.process_packet(pkt)
  File "/opt/ofp_sniffer/apps/ofp_proxies.py", line 104, in process_packet
    lldp = get_protocol(msg.ofp.data, lldp=True)
  File "/opt/ofp_sniffer/libs/tcpiplib/process_data.py", line 165, in get_protocol
    data = dissect_data(data)
  File "/opt/ofp_sniffer/libs/tcpiplib/process_data.py", line 26, in dissect_data
    eth.parse(packet[start:start + 14], 1)
  File "/opt/ofp_sniffer/libs/tcpiplib/packet.py", line 73, in parse
    ethernet = unpack('!6s6sH', eth_raw)
struct.error: unpack requires a buffer of 14 bytes

The length of eth_raw it seems is supposed to be enforced by slicing data---in line 26 in dissect_data, and in line 72 of parse---but this doesnt seem to actually work, the length is still 0:

>>> a = bytes('', 'utf-8')
>>> len(a)
0
>>> b = a[0:14]
>>> len(b)
0

I put together a really rudimentary patch, but it looks as though there are a few places this assumption is being made, it isnt crashing now but I get a lot of Error: unpack requires a buffer of 14 bytes popping up in my output. I figure it is probably better for me to hand this over to someone with a better idea of when and where this code is hit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant