-
Notifications
You must be signed in to change notification settings - Fork 34
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
templates: add checks for payload length and array size #19
Conversation
5ccba23
to
dbb67a9
Compare
@@ -166,7 +169,9 @@ void _@(msg_underscored_name)_decode(const CanardRxTransfer* transfer, uint32_t* | |||
@(ind)(void)bit_ofs; | |||
@(ind)(void)msg; | |||
@(ind)(void)tao; | |||
|
|||
@(ind)if (tao && (transfer->payload_len > @(msg_define_name.upper())_MAX_SIZE)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need this to be in the function above so we can return true to indicate a bad decode. Note that relying on bit_ofs to detect that we haven't decoded is not sufficient
templates/msg.h.em
Outdated
@@ -232,6 +237,9 @@ void _@(msg_underscored_name)_decode(const CanardRxTransfer* transfer, uint32_t* | |||
@[ end if]@ | |||
@{indent += 1}@{ind = ' '*indent}@ | |||
@[ end if]@ | |||
@(ind)if (msg->@(field.name).len > @(field.type.max_size)) { | |||
@(ind) msg->@(field.name).len = @(field.type.max_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we should change these void functions to bool. Unfortunately the convention is return true on invalid decode (that is completely crazy btw)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we should change these void functions to bool. Unfortunately the convention is return true on invalid decode (that is completely crazy btw)
The return true is to match the older version of the compiler.
use pragma for type limits
71af5c9
to
e8f8a8d
Compare
No description provided.