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

C deserialization function returns a false-positive invalid argument error for zero-sized buffers #221

Closed
pavel-kirienko opened this issue Nov 9, 2021 · 0 comments · Fixed by #232
Labels
bug Something isn't working trivial

Comments

@pavel-kirienko
Copy link
Member

Here:

https://github.com/UAVCAN/nunavut/blob/a90eac2749c1466bdff71a5bf19085e0c2de2299/src/nunavut/lang/c/templates/deserialization.j2#L14

If *inout_buffer_size_bytes == 0, buffer may be NULL because there is no data to deserialize, which is not an error.

The check should be updated like:

-- (buffer == {{ valuetoken_null }})
++ ((buffer == {{ valuetoken_null }}) && (0 != *inout_buffer_size_bytes))

This is a problem because libcanard intentionally emits null payload pointers for zero-sized payloads (as documented).

@pavel-kirienko pavel-kirienko added bug Something isn't working trivial labels Nov 9, 2021
thirtytwobits added a commit to thirtytwobits/nunavut that referenced this issue Dec 15, 2021
closes OpenCyphal#221
Bump version number for release.
thirtytwobits added a commit that referenced this issue Dec 16, 2021
* Fixing deserialization logic error in C

closes #221
Bump version number for release.

* Update src/nunavut/lang/c/templates/deserialization.j2

Co-authored-by: Pavel Kirienko <pavel.kirienko@gmail.com>

* fixing build and adding zero extension test

Co-authored-by: Pavel Kirienko <pavel.kirienko@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working trivial
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant