From c1b72a71b5d5f35914b87d8c302e0fa4611d9c3d Mon Sep 17 00:00:00 2001 From: Tymoteusz Bloch Date: Thu, 23 May 2019 18:53:44 +0200 Subject: [PATCH] Fixed LWIP warning issues found by Coverity scan --- features/lwipstack/lwip/src/api/lwip_api_msg.c | 2 +- features/lwipstack/lwip/src/core/ipv4/lwip_ip4_frag.c | 9 ++++++--- features/lwipstack/lwip/src/core/lwip_dns.c | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/features/lwipstack/lwip/src/api/lwip_api_msg.c b/features/lwipstack/lwip/src/api/lwip_api_msg.c index e7627418456..afad4f15920 100644 --- a/features/lwipstack/lwip/src/api/lwip_api_msg.c +++ b/features/lwipstack/lwip/src/api/lwip_api_msg.c @@ -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; diff --git a/features/lwipstack/lwip/src/core/ipv4/lwip_ip4_frag.c b/features/lwipstack/lwip/src/core/ipv4/lwip_ip4_frag.c index a445530e043..b56ac23df15 100644 --- a/features/lwipstack/lwip/src/core/ipv4/lwip_ip4_frag.c +++ b/features/lwipstack/lwip/src/core/ipv4/lwip_ip4_frag.c @@ -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. */ - ip_reass_dequeue_datagram(ipr, prev); + 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 */ - ip_reass_dequeue_datagram(ipr, ipr_prev); - + 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); diff --git a/features/lwipstack/lwip/src/core/lwip_dns.c b/features/lwipstack/lwip/src/core/lwip_dns.c index bdbaeb9baa6..aef9dc5ca20 100644 --- a/features/lwipstack/lwip/src/core/lwip_dns.c +++ b/features/lwipstack/lwip/src/core/lwip_dns.c @@ -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;