[netfilter-cvslog] r4169 - trunk/patch-o-matic-ng/patchlets/u32/linux-2.6/net/ipv4/netfilter

laforge at netfilter.org laforge at netfilter.org
Fri Jul 29 13:57:04 CEST 2005


Author: laforge at netfilter.org
Date: 2005-07-29 13:57:04 +0200 (Fri, 29 Jul 2005)
New Revision: 4169

Modified:
   trunk/patch-o-matic-ng/patchlets/u32/linux-2.6/net/ipv4/netfilter/ipt_u32.c
Log:
fix u32 header offset calculation (Giuseppe Della Bianca <bepi at adria.it>)
(Closes: #355)


Modified: trunk/patch-o-matic-ng/patchlets/u32/linux-2.6/net/ipv4/netfilter/ipt_u32.c
===================================================================
--- trunk/patch-o-matic-ng/patchlets/u32/linux-2.6/net/ipv4/netfilter/ipt_u32.c	2005-07-29 11:11:08 UTC (rev 4168)
+++ trunk/patch-o-matic-ng/patchlets/u32/linux-2.6/net/ipv4/netfilter/ipt_u32.c	2005-07-29 11:57:04 UTC (rev 4169)
@@ -134,21 +134,20 @@
 	int nnums, nvals;
 	u_int32_t pos, val;
 
+	u_int32_t AttPos;
+
 	LOCK_BH(&u32_lock);
 
 	head = skb_header_pointer(skb, 0, skb->len, u32_buffer);
 	BUG_ON(head == NULL);
 
-	origbase = head + (((void *)skb->nh.iph) - ((void *)skb->head));
-	end = head + (skb->end - skb->head);
-	base = origbase;
-
+	base = head;
 	/* unsigned long long cycles1, cycles2, cycles3, cycles4;
 	   cycles1 = get_cycles(); */
 	for (testind=0; testind < data->ntests; testind++) {
-		base = origbase; /* reset for each test */
+	        AttPos = 0;
 		pos = data->tests[testind].location[0].number;
-		if (base+pos+3 > end || base+pos < head) {
+		if (AttPos + pos + 3 > skb->len || AttPos + pos < 0){
 			UNLOCK_BH(&u32_lock);
 			return 0;
 		}
@@ -168,12 +167,15 @@
 				val = val >> number; 
 				break;
 			case IPT_U32_AT:
-				base = base + val;
+				AttPos += val;
 				pos = number;
-				if (base+pos+3 > end || base+pos < head) 
+				if (AttPos + pos + 3 > skb->len || AttPos + pos < 0) 
 					return 0;
-				val = (base[pos]<<24) + (base[pos+1]<<16) +
-					(base[pos+2]<<8) + base[pos+3];
+
+				val = (base[AttPos + pos]<<24) 
+				     +(base[AttPos + pos + 1]<<16)
+				     +(base[AttPos + pos + 2]<<8) 
+				     + base[AttPos + pos + 3];
 				break;
 			}
 		}




More information about the netfilter-cvslog mailing list