Skip to content

Commit 3524877

Browse files
author
Arto Kinnunen
authored
Fix issues found by coverity (#2082)
Fix issues found by coverity -324809 Dereference after null check (thread_extension_bbr.c) -348373 Dereference after null check (dhcpv6_client_service.c) -348840 Misuse of memcmp-style function (ws_pae_controller.c) -324625 Unchecked return value (thread_extension.c) -324547 Wrong size argument (ws_pae_supp.c)
1 parent e5f1627 commit 3524877

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

source/6LoWPAN/Thread/thread_extension.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -661,11 +661,11 @@ void thread_extension_child_address_registration_response_process(struct protoco
661661
return;
662662
}
663663
// We will start address registration timers
664-
665664
if (!thread_address_registration_running()) {
666-
uint32_t dua_delay = randLIB_get_random_in_range(1, 5);
667-
thread_extension_primary_bbr_get(interface, NULL, NULL, NULL, &dua_delay);
668-
665+
uint32_t dua_delay;
666+
if (0 != thread_extension_primary_bbr_get(interface, NULL, NULL, NULL, &dua_delay)) {
667+
dua_delay = randLIB_get_random_in_range(1, 5);
668+
}
669669
thread_address_registration_init();
670670
thread_address_registration_timer_set(interface, 1 + randLIB_get_random_in_range(0, dua_delay / 1000), randLIB_get_random_in_range(1, 5));
671671
}

source/6LoWPAN/Thread/thread_extension_bbr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1543,7 +1543,7 @@ void thread_extension_bbr_mcast_fwd_check(int8_t interface_id, bool *multicast_f
15431543
{
15441544
thread_pbbr_t *this = thread_bbr_find_by_interface(interface_id);
15451545

1546-
if (!this || multicast_fwd) {
1546+
if (!this || !multicast_fwd) {
15471547
return;
15481548
}
15491549

@@ -1557,6 +1557,7 @@ void thread_extension_bbr_mcast_fwd_check(int8_t interface_id, bool *multicast_f
15571557
*multicast_fwd = true;
15581558
return;
15591559
}
1560+
15601561
if (0 == thread_extension_primary_bbr_get(cur, NULL, NULL, NULL, NULL)) {
15611562
// We are secondary BBR we newer forward
15621563
*multicast_fwd = false;

source/6LoWPAN/ws/ws_pae_controller.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ static int8_t ws_pae_controller_nw_key_check_and_insert(protocol_interface_info_
293293
for (uint8_t i = 0; i < GTK_NUM; i++) {
294294
// If hash is set for a key
295295
if (!sec_prot_keys_gtk_hash_empty(gtk_hash_ptr)) {
296-
int8_t hash_matches = memcmp(gtk_hash_ptr, nw_key[i].hash, GTK_HASH_LEN);
296+
int hash_matches = memcmp(gtk_hash_ptr, nw_key[i].hash, GTK_HASH_LEN);
297297
// If the hash does not match (not set or modified) or not installed
298298
if (hash_matches != 0 || !nw_key[i].installed) {
299299

source/6LoWPAN/ws/ws_pae_supp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ static void ws_pae_supp_kmp_service_addr_get(kmp_service_t *service, kmp_api_t *
914914
if (pae_supp->new_br_eui_64_set && kmp_api_type_get(kmp) >= IEEE_802_1X_INITIAL_KEY) {
915915
kmp_address_eui_64_set(remote_addr, pae_supp->new_br_eui_64);
916916
} else {
917-
memset(remote_addr, 0, 8);
917+
memset(remote_addr, 0, sizeof(kmp_addr_t));
918918
tr_error("No border router EUI-64");
919919
}
920920
}

source/DHCPv6_client/dhcpv6_client_service.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,9 @@ void dhcpv6_renew(protocol_interface_info_entry_t *interface, if_address_entry_t
440440
srv_data_ptr->transActionId = dhcp_service_send_req(dhcp_client.service_instance, 0, srv_data_ptr, server_address, payload_ptr, payload_len, dhcp_solicit_resp_cb);
441441
if (srv_data_ptr->transActionId == 0) {
442442
ns_dyn_mem_free(payload_ptr);
443-
addr->state_timer = 200; //Retry after 20 seconds
443+
if (addr) {
444+
addr->state_timer = 200; //Retry after 20 seconds
445+
}
444446
tr_error("DHCP renew send failed");
445447
}
446448
if (packetReq.messageType == DHCPV6_SOLICATION_TYPE && dhcp_client.sol_timeout != 0) {

0 commit comments

Comments
 (0)