1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-01 20:33:08 +02:00
openwrt-xburst/package/busybox/patches/450-truncated_ping_results.patch
nbd ff54f54165 hopefully fix ping bugs introduced in [6443]
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@6505 3c298f89-4303-0410-b956-a3cf2f4a3e73
2007-03-04 14:36:34 +00:00

32 lines
1022 B
Diff

--- busybox-1.4.1/networking/ping.c 2007-01-24 22:34:34.000000000 +0100
+++ busybox-1.4.1.new/networking/ping.c 2007-02-28 20:35:59.000000000 +0100
@@ -70,7 +70,7 @@
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();
@@ -86,7 +86,7 @@
pkt->icmp_type = ICMP_ECHO;
pkt->icmp_cksum = in_cksum((unsigned short *) pkt, sizeof(packet));
- c = sendto(pingsock, packet, DEFDATALEN + ICMP_MINLEN, 0,
+ c = sendto(pingsock, packet, datalen + ICMP_MINLEN, 0,
(struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in));
if (c < 0) {
@@ -274,6 +274,10 @@
++nreceived;
tp = (struct timeval *) icmppkt->icmp_data;
+ /* If packet is too short, results will be truncated */
+ if (sz < (ICMP_MINLEN + sizeof(tv.tv_sec) + sizeof(tv.tv_usec)))
+ return;
+
if ((tv.tv_usec -= tp->tv_usec) < 0) {
--tv.tv_sec;
tv.tv_usec += 1000000;