Skip to content

Commit

Permalink
canbus: isotp: convert SF length check from ASSERT to runtime check
Browse files Browse the repository at this point in the history
Convert the ISO-TP SF length check in send_sf() from __ASSERT() to a
runtime check.

Fixes: #61501

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
(cherry picked from commit 1b3d1e0)
  • Loading branch information
henrikbrixandersen authored and fabiobaltieri committed Aug 22, 2023
1 parent 099e013 commit 11a493c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion subsys/canbus/isotp/isotp.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,11 @@ static inline int send_sf(struct isotp_send_ctx *ctx)

frame.data[index++] = ISOTP_PCI_TYPE_SF | len;

__ASSERT_NO_MSG(len <= ISOTP_CAN_DL - index);
if (len > ISOTP_CAN_DL - index) {
LOG_ERR("SF len does not fit DL");
return -ENOSPC;
}

memcpy(&frame.data[index], data, len);

#ifdef CONFIG_ISOTP_ENABLE_TX_PADDING
Expand Down

0 comments on commit 11a493c

Please sign in to comment.