From 7f7d019b25b0d663142f44cc335e66d36095692c Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Fri, 17 Nov 2023 12:02:13 +0100 Subject: [PATCH] net: lwm2m: Add error checks for option encoding in BS registration Add missing error checks when encoding CoAP options for Bootstrap Register message Signed-off-by: Robert Lubos --- subsys/net/lib/lwm2m/lwm2m_rd_client.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/subsys/net/lib/lwm2m/lwm2m_rd_client.c b/subsys/net/lib/lwm2m/lwm2m_rd_client.c index ca539fcded..d9f2e229ed 100644 --- a/subsys/net/lib/lwm2m/lwm2m_rd_client.c +++ b/subsys/net/lib/lwm2m/lwm2m_rd_client.c @@ -770,16 +770,20 @@ static int sm_send_bootstrap_registration(void) goto cleanup; } - /* TODO: handle return error */ - coap_packet_append_option(&msg->cpkt, COAP_OPTION_URI_PATH, - "bs", strlen("bs")); + ret = coap_packet_append_option(&msg->cpkt, COAP_OPTION_URI_PATH, + "bs", strlen("bs")); + if (ret < 0) { + goto cleanup; + } snprintk(query_buffer, sizeof(query_buffer) - 1, "ep=%s", client.ep_name); - /* TODO: handle return error */ - coap_packet_append_option(&msg->cpkt, COAP_OPTION_URI_QUERY, - query_buffer, strlen(query_buffer)); + ret = coap_packet_append_option(&msg->cpkt, COAP_OPTION_URI_QUERY, + query_buffer, strlen(query_buffer)); + if (ret < 0) { + goto cleanup; + } if (IS_ENABLED(CONFIG_LWM2M_VERSION_1_1)) { int pct = LWM2M_FORMAT_OMA_TLV;