aboutsummaryrefslogtreecommitdiffstats
path: root/package/busybox
diff options
context:
space:
mode:
authorFlorian Fainelli <florian@openwrt.org>2007-02-28 19:45:36 +0000
committerFlorian Fainelli <florian@openwrt.org>2007-02-28 19:45:36 +0000
commit5a85d2f171d118c77e683feb9088a9c1fa5fd0bb (patch)
tree14fd152d403d774d98573633b433621d31841aad /package/busybox
parent556ff80527f0f825b2f1c19072668443e36b3a5c (diff)
downloadmaster-187ad058-5a85d2f171d118c77e683feb9088a9c1fa5fd0bb.tar.gz
master-187ad058-5a85d2f171d118c77e683feb9088a9c1fa5fd0bb.tar.bz2
master-187ad058-5a85d2f171d118c77e683feb9088a9c1fa5fd0bb.zip
Fix truncated pings results when packets are too small. Also check for packet maximum size, so that busybox's ping could not be responsible for flooding hosts.
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@6443 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/busybox')
-rw-r--r--package/busybox/patches/450-truncated_ping_results.patch42
1 files changed, 42 insertions, 0 deletions
diff --git a/package/busybox/patches/450-truncated_ping_results.patch b/package/busybox/patches/450-truncated_ping_results.patch
new file mode 100644
index 0000000000..30e86701a3
--- /dev/null
+++ b/package/busybox/patches/450-truncated_ping_results.patch
@@ -0,0 +1,42 @@
+--- 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 + 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) {
+@@ -257,8 +257,8 @@
+
+ gettimeofday(&tv, NULL);
+
+- /* discard if too short */
+- if (sz < (datalen + ICMP_MINLEN))
++ /* discard if too short / long */
++ if (sz < (datalen + ICMP_MINLEN) || sz > (MAXICMPLEN))
+ return;
+
+ /* check IP header */
+@@ -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;