[package] fix busybox's ping compilation when the fancy feature is turned off (#6489)
[openwrt.git] / package / busybox / patches / 460-truncated_ping_results.patch
1 Index: busybox-1.15.3/networking/ping.c
2 ===================================================================
3 --- busybox-1.15.3.orig/networking/ping.c       2010-02-28 13:47:00.000000000 +0100
4 +++ busybox-1.15.3/networking/ping.c    2010-02-28 13:47:19.000000000 +0100
5 @@ -79,6 +79,7 @@
6  /* simple version */
7  
8  static char *hostname;
9 +static unsigned datalen = DEFDATALEN;
10  
11  static void noresp(int ign UNUSED_PARAM)
12  {
13 @@ -91,7 +92,7 @@
14         struct sockaddr_in pingaddr;
15         struct icmp *pkt;
16         int pingsock, c;
17 -       char packet[DEFDATALEN + MAXIPLEN + MAXICMPLEN];
18 +       char packet[datalen + ICMP_MINLEN + MAXIPLEN + MAXICMPLEN];
19  
20         pingsock = create_icmp_socket();
21         pingaddr = lsa->u.sin;
22 @@ -101,7 +102,7 @@
23         pkt->icmp_type = ICMP_ECHO;
24         pkt->icmp_cksum = in_cksum((unsigned short *) pkt, sizeof(packet));
25  
26 -       c = xsendto(pingsock, packet, DEFDATALEN + ICMP_MINLEN,
27 +       c = xsendto(pingsock, packet, datalen + ICMP_MINLEN,
28                            (struct sockaddr *) &pingaddr, sizeof(pingaddr));
29  
30         /* listen for replies */
31 @@ -135,7 +136,7 @@
32         struct icmp6_hdr *pkt;
33         int pingsock, c;
34         int sockopt;
35 -       char packet[DEFDATALEN + MAXIPLEN + MAXICMPLEN];
36 +       char packet[datalen + ICMP_MINLEN + MAXIPLEN + MAXICMPLEN];
37  
38         pingsock = create_icmp6_socket();
39         pingaddr = lsa->u.sin6;
40 @@ -147,7 +148,7 @@
41         sockopt = offsetof(struct icmp6_hdr, icmp6_cksum);
42         setsockopt(pingsock, SOL_RAW, IPV6_CHECKSUM, &sockopt, sizeof(sockopt));
43  
44 -       c = xsendto(pingsock, packet, DEFDATALEN + sizeof (struct icmp6_hdr),
45 +       c = xsendto(pingsock, packet, datalen + sizeof (struct icmp6_hdr),
46                            (struct sockaddr *) &pingaddr, sizeof(pingaddr));
47  
48         /* listen for replies */