From dc404c47f7b732add6a1ed20967e7cc5be7921c7 Mon Sep 17 00:00:00 2001 From: Arto Kinnunen Date: Thu, 1 Nov 2018 16:03:36 +0200 Subject: [PATCH] Fix issues found by coverity (#1889) - 277905 Unchecked return value from library - 277906 Unchecked return value from library - 270649 Uninitialized scalar variable --- source/6LoWPAN/Thread/thread_joiner_application.c | 2 +- source/6LoWPAN/Thread/thread_nvm_store.c | 12 ++++++++++-- source/6LoWPAN/ws/ws_bootstrap.c | 8 ++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/source/6LoWPAN/Thread/thread_joiner_application.c b/source/6LoWPAN/Thread/thread_joiner_application.c index 5bc1b7849362..741cbd656c12 100644 --- a/source/6LoWPAN/Thread/thread_joiner_application.c +++ b/source/6LoWPAN/Thread/thread_joiner_application.c @@ -1140,7 +1140,7 @@ void thread_joiner_pending_config_activate(int8_t interface_id) this->active_configuration_ptr->timestamp = pending_active_timestamp; // All information is copied from old configuration so if configuration is corrupt we dont change anything. this->pending_configuration_ptr = NULL; - (void)thread_nvm_store_pending_configuration_remove(); + thread_nvm_store_pending_configuration_remove(); configuration_set_copy_mandatory(this->active_configuration_ptr, this->old_active_configuration_ptr); link_configuration_update(this->configuration_ptr,this->active_configuration_ptr->data, this->active_configuration_ptr->length); link_configuration_trace(this->configuration_ptr); diff --git a/source/6LoWPAN/Thread/thread_nvm_store.c b/source/6LoWPAN/Thread/thread_nvm_store.c index 0aa4657f687e..18a1918b04b2 100644 --- a/source/6LoWPAN/Thread/thread_nvm_store.c +++ b/source/6LoWPAN/Thread/thread_nvm_store.c @@ -292,7 +292,11 @@ int thread_nvm_store_active_configuration_remove(void) } char ac_data_path[ACTIVE_CONF_STRING_LEN]; thread_nvm_store_create_path(ac_data_path, THREAD_NVM_ACTIVE_CONF_FILE); - return remove(ac_data_path); + int status = remove(ac_data_path); + if (status != 0) { + return THREAD_NVM_FILE_REMOVE_ERROR; + } + return THREAD_NVM_FILE_SUCCESS; } int thread_nvm_store_pending_configuration_remove(void) @@ -302,7 +306,11 @@ int thread_nvm_store_pending_configuration_remove(void) } char ac_data_path[PENDING_CONF_STRING_LEN]; thread_nvm_store_create_path(ac_data_path, THREAD_NVM_PENDING_CONF_FILE); - return remove(ac_data_path); + int status = remove(ac_data_path); + if (status != 0) { + return THREAD_NVM_FILE_REMOVE_ERROR; + } + return THREAD_NVM_FILE_SUCCESS; } diff --git a/source/6LoWPAN/ws/ws_bootstrap.c b/source/6LoWPAN/ws/ws_bootstrap.c index 024ea2df49b5..e0f1987e63f1 100644 --- a/source/6LoWPAN/ws/ws_bootstrap.c +++ b/source/6LoWPAN/ws/ws_bootstrap.c @@ -834,8 +834,12 @@ static void ws_bootstrap_pan_advertisement_analyse(struct protocol_interface_inf // Saved from unicast IE cur->ws_info->parent_info.ws_us = *ws_us; - // Saved from Pan information - cur->ws_info->parent_info.pan_information = pan_information; + // Saved from Pan information, do not overwrite pan_version as it is not valid here + cur->ws_info->parent_info.pan_information.pan_size = pan_information.pan_size; + cur->ws_info->parent_info.pan_information.routing_cost = pan_information.routing_cost; + cur->ws_info->parent_info.pan_information.use_parent_bs = pan_information.use_parent_bs; + cur->ws_info->parent_info.pan_information.rpl_routing_method = pan_information.rpl_routing_method; + cur->ws_info->parent_info.pan_information.version = pan_information.version; // Saved from message cur->ws_info->parent_info.timestamp = data->timestamp;