From 1b3d1e01deff942ef84cb08e9fa9b4c5e18de385 Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Tue, 15 Aug 2023 14:23:29 +0200 Subject: [PATCH] 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 --- subsys/canbus/isotp/isotp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/subsys/canbus/isotp/isotp.c b/subsys/canbus/isotp/isotp.c index dfe43bb9e24..d2b16d24a7c 100644 --- a/subsys/canbus/isotp/isotp.c +++ b/subsys/canbus/isotp/isotp.c @@ -881,7 +881,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