The 'code' field in ICMPv4 and ICMPv6 echo messages didn't use to
be explicitly set to zero, which resulted in malformed ping packets
(with incorrect code) being generated in case a custom payload
pattern was set using the '-p' command line option.
---
 networking/ping.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/networking/ping.c b/networking/ping.c
index 9805695a1..1c387353f 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -563,7 +563,7 @@ static void sendping4(int junk UNUSED_PARAM)
 
        memset(pkt, G.pattern, datalen + ICMP_MINLEN + 4);
        pkt->icmp_type = ICMP_ECHO;
-       /*pkt->icmp_code = 0;*/
+       pkt->icmp_code = 0;
        pkt->icmp_cksum = 0; /* cksum is calculated with this field set to 0 */
        pkt->icmp_seq = htons(G.ntransmitted); /* don't ++ here, it can be a 
macro */
        pkt->icmp_id = myid;
@@ -586,7 +586,7 @@ static void sendping6(int junk UNUSED_PARAM)
 
        memset(pkt, G.pattern, datalen + sizeof(struct icmp6_hdr) + 4);
        pkt->icmp6_type = ICMP6_ECHO_REQUEST;
-       /*pkt->icmp6_code = 0;*/
+       pkt->icmp6_code = 0;
        /*pkt->icmp6_cksum = 0;*/
        pkt->icmp6_seq = htons(G.ntransmitted); /* don't ++ here, it can be a 
macro */
        pkt->icmp6_id = myid;
-- 
2.38.1

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to