Skip to content

Crash in ip connection on invalid packet #57

@PatrickBaus

Description

@PatrickBaus

I am not entirely sure, if this is the correct repo for this report. I do have a problem with some of the bricks in a noisy environment. Noisy in this context means, that every once in a while the MCU on the Master Brick seems to send garbarge and if the ip connection receives this garbarge, its thread crashes.

I am using the Python implementation and I have the following taceback:

Exception in thread Brickd-Receiver:
Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.9/threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "/sensorDaemon/sensors/tinkerforge/ip_connection.py", line 1052, in receive_loop
    self.handle_response(packet)
  File "/sensorDaemon/sensors/tinkerforge/ip_connection.py", line 1355, in handle_response
    function_id = get_function_id_from_data(packet)
  File "/sensorDaemon/sensors/tinkerforge/ip_connection.py", line 41, in get_function_id_from_data
    return struct.unpack('<B', data[5:6])[0]
struct.error: unpack requires a buffer of 1 bytes 

It would be nice to see some kind of exception handling, when unpacking structs coming from untrustworthy sources.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions