Skip to content

Commit 7f4c587

Browse files
henrikbrixandersenjgl-meta
authored andcommitted
canbus: isotp: convert SF length check from ASSERT to runtime check
Convert the ISO-TP SF length check in send_sf() from __ASSERT() to a runtime check. Fixes: #61501 Signed-off-by: Henrik Brix Andersen <[email protected]> (cherry picked from commit 1b3d1e0)
1 parent 422a3d8 commit 7f4c587

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

subsys/canbus/isotp/isotp.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,11 @@ static inline int send_sf(struct isotp_send_ctx *ctx)
882882

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

885-
__ASSERT_NO_MSG(len <= ISOTP_CAN_DL - index);
885+
if (len > ISOTP_CAN_DL - index) {
886+
LOG_ERR("SF len does not fit DL");
887+
return -ENOSPC;
888+
}
889+
886890
memcpy(&frame.data[index], data, len);
887891

888892
#ifdef CONFIG_ISOTP_ENABLE_TX_PADDING

0 commit comments

Comments
 (0)