hopefully fix ping bugs introduced in [6443]
[openwrt.git] / package / busybox / patches / 450-truncated_ping_results.patch
1 --- busybox-1.4.1/networking/ping.c 2007-01-24 22:34:34.000000000 +0100
2 +++ busybox-1.4.1.new/networking/ping.c 2007-02-28 20:35:59.000000000 +0100
3 @@ -70,7 +70,7 @@
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
12 @@ -86,7 +86,7 @@
13 pkt->icmp_type = ICMP_ECHO;
14 pkt->icmp_cksum = in_cksum((unsigned short *) pkt, sizeof(packet));
15
16 - c = sendto(pingsock, packet, DEFDATALEN + ICMP_MINLEN, 0,
17 + c = sendto(pingsock, packet, datalen + ICMP_MINLEN, 0,
18 (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in));
19
20 if (c < 0) {
21 @@ -274,6 +274,10 @@
22 ++nreceived;
23 tp = (struct timeval *) icmppkt->icmp_data;
24
25 + /* If packet is too short, results will be truncated */
26 + if (sz < (ICMP_MINLEN + sizeof(tv.tv_sec) + sizeof(tv.tv_usec)))
27 + return;
28 +
29 if ((tv.tv_usec -= tp->tv_usec) < 0) {
30 --tv.tv_sec;
31 tv.tv_usec += 1000000;
This page took 0.046656 seconds and 5 git commands to generate.