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
4 struct sockaddr_in pingaddr;
7 - char packet[DEFDATALEN + MAXIPLEN + MAXICMPLEN];
8 + char packet[datalen + MAXIPLEN + MAXICMPLEN];
10 pingsock = create_icmp_socket();
13 pkt->icmp_type = ICMP_ECHO;
14 pkt->icmp_cksum = in_cksum((unsigned short *) pkt, sizeof(packet));
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));
23 gettimeofday(&tv, NULL);
25 - /* discard if too short */
26 - if (sz < (datalen + ICMP_MINLEN))
27 + /* discard if too short / long */
28 + if (sz < (datalen + ICMP_MINLEN) || sz > (MAXICMPLEN))
34 tp = (struct timeval *) icmppkt->icmp_data;
36 + /* If packet is too short, results will be truncated */
37 + if (sz < (ICMP_MINLEN + sizeof(tv.tv_sec) + sizeof(tv.tv_usec)))
40 if ((tv.tv_usec -= tp->tv_usec) < 0) {
42 tv.tv_usec += 1000000;