[tools] fix segfault when using the maxlen argument (#4359)
[openwrt.git] / package / busybox / patches / 460-truncated_ping_results.patch
1 --- a/networking/ping.c
2 +++ b/networking/ping.c
3 @@ -91,7 +91,7 @@ static void ping4(len_and_sockaddr *lsa)
4 struct sockaddr_in pingaddr;
5 struct icmp *pkt;
6 int pingsock, c;
7 - char packet[DEFDATALEN + MAXIPLEN + MAXICMPLEN];
8 + char packet[datalen + ICMP_MINLEN + MAXIPLEN + MAXICMPLEN];
9
10 pingsock = create_icmp_socket();
11 pingaddr = lsa->u.sin;
12 @@ -101,7 +101,7 @@ static void ping4(len_and_sockaddr *lsa)
13 pkt->icmp_type = ICMP_ECHO;
14 pkt->icmp_cksum = in_cksum((unsigned short *) pkt, sizeof(packet));
15
16 - c = xsendto(pingsock, packet, DEFDATALEN + ICMP_MINLEN,
17 + c = xsendto(pingsock, packet, datalen + ICMP_MINLEN,
18 (struct sockaddr *) &pingaddr, sizeof(pingaddr));
19
20 /* listen for replies */
21 @@ -135,7 +135,7 @@ static void ping6(len_and_sockaddr *lsa)
22 struct icmp6_hdr *pkt;
23 int pingsock, c;
24 int sockopt;
25 - char packet[DEFDATALEN + MAXIPLEN + MAXICMPLEN];
26 + char packet[datalen + ICMP_MINLEN + MAXIPLEN + MAXICMPLEN];
27
28 pingsock = create_icmp6_socket();
29 pingaddr = lsa->u.sin6;
30 @@ -147,7 +147,7 @@ static void ping6(len_and_sockaddr *lsa)
31 sockopt = offsetof(struct icmp6_hdr, icmp6_cksum);
32 setsockopt(pingsock, SOL_RAW, IPV6_CHECKSUM, &sockopt, sizeof(sockopt));
33
34 - c = xsendto(pingsock, packet, DEFDATALEN + sizeof (struct icmp6_hdr),
35 + c = xsendto(pingsock, packet, datalen + sizeof (struct icmp6_hdr),
36 (struct sockaddr *) &pingaddr, sizeof(pingaddr));
37
38 /* listen for replies */
This page took 0.045657 seconds and 5 git commands to generate.