From 1c1587eef661cbdf16a92794aa3d99449193a851 Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Wed, 10 Feb 2016 20:35:58 +0100 Subject: [PATCH] ICMP: Fix responses were always sent to default netif because of uninitialized source IP (found by Coverity) --- src/core/ipv4/icmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/ipv4/icmp.c b/src/core/ipv4/icmp.c index 19e63bbb..4996b682 100644 --- a/src/core/ipv4/icmp.c +++ b/src/core/ipv4/icmp.c @@ -359,6 +359,7 @@ icmp_send_response(struct pbuf *p, u8_t type, u8_t code) SMEMCPY((u8_t *)q->payload + sizeof(struct icmp_echo_hdr), (u8_t *)p->payload, IP_HLEN + ICMP_DEST_UNREACH_DATASIZE); + ip4_addr_copy(iphdr_src, iphdr->src); netif = ip4_route(&iphdr_src); if (netif != NULL) { /* calculate checksum */ @@ -369,7 +370,6 @@ icmp_send_response(struct pbuf *p, u8_t type, u8_t code) } #endif ICMP_STATS_INC(icmp.xmit); - ip4_addr_copy(iphdr_src, iphdr->src); ip4_output_if(q, NULL, &iphdr_src, ICMP_TTL, 0, IP_PROTO_ICMP, netif); } pbuf_free(q);