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

Crash in ip connection on invalid packet #57

Open
PatrickBaus opened this issue Sep 25, 2021 · 1 comment
Open

Crash in ip connection on invalid packet #57

PatrickBaus opened this issue Sep 25, 2021 · 1 comment

Comments

@PatrickBaus
Copy link

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.

@photron
Copy link
Member

photron commented Sep 27, 2021

This is a known problem in all the bindings. It's on the TODO list to be fixed. The fix will be to verify the incoming data in a more strict way before interpreting it. If garbage is received the IP Connection will disconnect and auto-reconnect (if enabled) to synchronize again.

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

2 participants