From 68c7bfc20d24ec36acda265cb27db757df1078e9 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Mon, 8 Apr 2024 16:33:44 +0200 Subject: [PATCH] sys/suit: return error when URL buffer is too small --- sys/suit/handlers_command_seq.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/suit/handlers_command_seq.c b/sys/suit/handlers_command_seq.c index ab63409956b6..d03a266043c1 100644 --- a/sys/suit/handlers_command_seq.c +++ b/sys/suit/handlers_command_seq.c @@ -424,7 +424,10 @@ static int _dtv_fetch(suit_manifest_t *manifest, int key, return err; } - assert(manifest->urlbuf && url_len < manifest->urlbuf_len); + if (!manifest->urlbuf || url_len >= manifest->urlbuf_len) { + assert(0); + return SUIT_ERR_NO_MEM; + } memcpy(manifest->urlbuf, url, url_len); manifest->urlbuf[url_len] = '\0';