The function odid_message_build_pack
will call different enconding call like 'encodeBasicIDMessage', 'encodeLocationMessage' and so on.
The problem is, those encode function CAN fail, and if they do, the error is ignored
Current code:
if (UAS_Data->LocationValid) {
if (msg_pack.MsgPackSize >= ODID_PACK_MAX_MESSAGES)
return -EINVAL;
encodeLocationMessage((void *)&msg_pack.Messages[msg_pack.MsgPackSize], &UAS_Data->Location);
msg_pack.MsgPackSize++;
}
The quick and proper fix is very simple, we do to NOT increment msg_pack.MsgPackSize on failure:
if (UAS_Data->LocationValid) {
if (msg_pack.MsgPackSize >= ODID_PACK_MAX_MESSAGES)
return -EINVAL;
if (encodeLocationMessage((void *)&msg_pack.Messages[msg_pack.MsgPackSize], &UAS_Data->Location) == ODID_SUCCESS)
msg_pack.MsgPackSize++;
}
this will make sure that the invalid message will be override by the next message, or ignored if last one
The function
odid_message_build_pack
will call different enconding call like 'encodeBasicIDMessage', 'encodeLocationMessage' and so on. The problem is, those encode function CAN fail, and if they do, the error is ignoredCurrent code:
The quick and proper fix is very simple, we do to NOT increment
msg_pack.MsgPackSize
on failure:this will make sure that the invalid message will be override by the next message, or ignored if last one