OpenCyphal / libcanard

A compact implementation of the Cyphal/CAN protocol in C for high-integrity real-time embedded systems
http://opencyphal.org
MIT License
327 stars 192 forks source link

Fix crush single message inside long message #190

Closed a1ien closed 2 years ago

a1ien commented 2 years ago

Without this check we can crash here https://github.com/UAVCAN/libcanard/blob/legacy-v0/canard.c#L340-L357 This happen because when processing single frame transfer we check that state->buffer_blocks == NULL But if inside multi frame transfer we receive single frame transfer this assert can happen. This problem happened in real environment.

a1ien commented 2 years ago

I am not sure but this maybe applied also to v1. I found similar check here https://github.com/UAVCAN/libcanard/blob/master/libcanard/canard.c#L835

coderkalyan commented 2 years ago

Looks good to me. @a1ien can you please add a test case to reproduce this error? (Let me know if you need assistance with that).

I'm still looking into the differences with the v1 code to see if we need to implement the same fix on v1 as well.

a1ien commented 2 years ago

Add test. But I am not sure how correct is it.

a1ien commented 2 years ago

ping @coderkalyan

coderkalyan commented 2 years ago

Oh, sorry. Let me take a look.