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 <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2023-11-17 12:02:13 +01:00 committed by Carles Cufí
parent ec50e5393c
commit 7f7d019b25

View file

@ -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;