From b34266b42b5f6f78b7346c9ca90caebcd59db345 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Tue, 29 Apr 2008 12:31:53 +0000 Subject: ping: dont leak uninitialized data in ping packets function old new delta sendping4 176 186 +10 sendping6 93 100 +7 --- networking/ping.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/networking/ping.c b/networking/ping.c index 299148641..c3a71071c 100644 --- a/networking/ping.c +++ b/networking/ping.c @@ -372,9 +372,10 @@ static void sendping4(int junk ATTRIBUTE_UNUSED) * *after* packet. Saves one if() */ struct icmp *pkt = alloca(datalen + ICMP_MINLEN + 4); + memset(pkt, 0, datalen + ICMP_MINLEN + 4); pkt->icmp_type = ICMP_ECHO; - pkt->icmp_code = 0; - pkt->icmp_cksum = 0; + /*pkt->icmp_code = 0;*/ + /*pkt->icmp_cksum = 0;*/ pkt->icmp_seq = htons(ntransmitted); /* don't ++ here, it can be a macro */ pkt->icmp_id = myid; @@ -391,9 +392,10 @@ static void sendping6(int junk ATTRIBUTE_UNUSED) { struct icmp6_hdr *pkt = alloca(datalen + sizeof(struct icmp6_hdr) + 4); + memset(pkt, 0, datalen + sizeof(struct icmp6_hdr) + 4); pkt->icmp6_type = ICMP6_ECHO_REQUEST; - pkt->icmp6_code = 0; - pkt->icmp6_cksum = 0; + /*pkt->icmp6_code = 0;*/ + /*pkt->icmp6_cksum = 0;*/ pkt->icmp6_seq = htons(ntransmitted); /* don't ++ here, it can be a macro */ pkt->icmp6_id = myid; -- cgit v1.2.3