Merge pull request #10647 from tymoteuszblochmobica/coverity

Fix LWIP warning issues found by Coverity scan

lwip_dns.c in function: dns_add_interface_server
CID 1399051 (#1 of 1): Buffer not null terminated (BUFFER_SIZE_WARNING)10. buffer_size_warning: Calling strncpy with a maximum size argument of 6 bytes on destination array new_interface_server->interface_name of size 6 bytes might leave the destination string unterminated.
line 434 strncpy(new_interface_server->interface_name, interface_name, INTERFACE_NAME_MAX_SIZE);

lwip_ip4_frag.c in function: ip_reass_free_complete_datagram

CID 1373164 (#1 of 1): Dereference after null check (FORWARD_NULL)7. var_deref_model: Passing null pointer prev to ip_reass_dequeue_datagram, which dereferences it. [show details]
line 209 ip_reass_dequeue_datagram(ipr, prev);

lwip_ip4_frag.c in function: ip_reass

CID 1373163 (#1-2 of 2): Dereference after null check (FORWARD_NULL)38. var_deref_model: Passing null pointer ipr_prev to ip_reass_dequeue_datagram, which dereferences it. [show details]
line 663 ip_reass_dequeue_datagram(ipr, ipr_prev);

lwip_api_msg.c in function: lwip_netconn_do_connected

CID 1373162 (#1 of 1): Explicit null dereferenced (FORWARD_NULL)10. var_deref_model: Passing null pointer op_completed_sem to sys_sem_signal, which dereferences it. [show details]
line 1336 sys_sem_signal(op_completed_sem);
pull/10741/head
Martin Kojtal 2019-06-03 08:41:53 +01:00 committed by GitHub
commit f0696417c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View File

@ -1332,7 +1332,7 @@ lwip_netconn_do_connected(void *arg, struct tcp_pcb *pcb, err_t err)
conn->state = NETCONN_NONE;
API_EVENT(conn, NETCONN_EVT_SENDPLUS, 0);
if (was_blocking) {
if (was_blocking && op_completed_sem != NULL) {
sys_sem_signal(op_completed_sem);
}
return ERR_OK;

View File

@ -206,7 +206,9 @@ ip_reass_free_complete_datagram(struct ip_reassdata *ipr, struct ip_reassdata *p
pbuf_free(pcur);
}
/* Then, unchain the struct ip_reassdata from the list and free it. */
if (prev != NULL) {
ip_reass_dequeue_datagram(ipr, prev);
}
LWIP_ASSERT("ip_reass_pbufcount >= pbufs_freed", ip_reass_pbufcount >= pbufs_freed);
ip_reass_pbufcount = (u16_t)(ip_reass_pbufcount - pbufs_freed);
@ -660,8 +662,9 @@ ip4_reass(struct pbuf *p)
}
/* release the sources allocate for the fragment queue entry */
if (ipr_prev != NULL) {
ip_reass_dequeue_datagram(ipr, ipr_prev);
}
/* and adjust the number of pbufs currently queued for reassembly. */
clen = pbuf_clen(p);
LWIP_ASSERT("ip_reass_pbufcount >= clen", ip_reass_pbufcount >= clen);

View File

@ -431,7 +431,7 @@ dns_add_interface_server(u8_t numdns, const char *interface_name, const ip_addr_
}
// add new dns server to the list tail
new_interface_server = mem_malloc(sizeof(struct dns_server_interface));
strncpy(new_interface_server->interface_name, interface_name, INTERFACE_NAME_MAX_SIZE);
snprintf(new_interface_server->interface_name, INTERFACE_NAME_MAX_SIZE, "%s",interface_name);
new_interface_server->dns_servers[numdns] = (*dnsserver);
new_interface_server->next = NULL;