summaryrefslogtreecommitdiffstats
path: root/package/busybox/patches/460-truncated_ping_results.patch
blob: 25f055549762bc47450d17178f0ff7d4db69e108 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -79,6 +79,7 @@ static int in_cksum(unsigned short *buf,
 /* simple version */
 
 static char *hostname;
+static unsigned datalen = DEFDATALEN;
 
 static void noresp(int ign UNUSED_PARAM)
 {
@@ -91,7 +92,7 @@ static void ping4(len_and_sockaddr *lsa)
 	struct sockaddr_in pingaddr;
 	struct icmp *pkt;
 	int pingsock, c;
-	char packet[DEFDATALEN + MAXIPLEN + MAXICMPLEN];
+	char packet[datalen + ICMP_MINLEN + MAXIPLEN + MAXICMPLEN];
 
 	pingsock = create_icmp_socket();
 	pingaddr = lsa->u.sin;
@@ -101,7 +102,7 @@ static void ping4(len_and_sockaddr *lsa)
 	pkt->icmp_type = ICMP_ECHO;
 	pkt->icmp_cksum = in_cksum((unsigned short *) pkt, sizeof(packet));
 
-	c = xsendto(pingsock, packet, DEFDATALEN + ICMP_MINLEN,
+	c = xsendto(pingsock, packet, datalen + ICMP_MINLEN,
 			   (struct sockaddr *) &pingaddr, sizeof(pingaddr));
 
 	/* listen for replies */
@@ -135,7 +136,7 @@ static void ping6(len_and_sockaddr *lsa)
 	struct icmp6_hdr *pkt;
 	int pingsock, c;
 	int sockopt;
-	char packet[DEFDATALEN + MAXIPLEN + MAXICMPLEN];
+	char packet[datalen + ICMP_MINLEN + MAXIPLEN + MAXICMPLEN];
 
 	pingsock = create_icmp6_socket();
 	pingaddr = lsa->u.sin6;
@@ -147,7 +148,7 @@ static void ping6(len_and_sockaddr *lsa)
 	sockopt = offsetof(struct icmp6_hdr, icmp6_cksum);
 	setsockopt(pingsock, SOL_RAW, IPV6_CHECKSUM, &sockopt, sizeof(sockopt));
 
-	c = xsendto(pingsock, packet, DEFDATALEN + sizeof (struct icmp6_hdr),
+	c = xsendto(pingsock, packet, datalen + sizeof (struct icmp6_hdr),
 			   (struct sockaddr *) &pingaddr, sizeof(pingaddr));
 
 	/* listen for replies */