ICMP: Fix responses were always sent to default netif because of uninitialized source IP (found by Coverity)

This commit is contained in:
Dirk Ziegelmeier 2016-02-10 20:35:58 +01:00
parent 11b810721a
commit 1c1587eef6

View File

@ -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);