Reject CAN frames with length > 8

Previously, they were just truncated.

In any case, this is only hit if the userspace daemon
gives us more than 8 bytes for CAN, which it shouldn't.
tx-receipts
Paul Hollinsky 2021-01-29 15:47:43 -05:00
parent 668e50d08c
commit 6bbcf1b527
1 changed files with 4 additions and 1 deletions

View File

@ -471,7 +471,10 @@ static int intrepid_fill_can_frame_from_neomessage(
if (msg->status.remoteFrame) if (msg->status.remoteFrame)
cf->can_id |= CAN_RTR_FLAG; cf->can_id |= CAN_RTR_FLAG;
cf->can_dlc = get_can_dlc(msg->length); if (unlikely(msg->length > 8))
return -1;
cf->can_dlc = msg->length;
memcpy(cf->data, data, cf->can_dlc); memcpy(cf->data, data, cf->can_dlc);
stats->rx_bytes += cf->can_dlc; stats->rx_bytes += cf->can_dlc;