Sophie

Sophie

distrib > Mandriva > 2009.0 > i586 > by-pkgid > 10a15d9497516af5af31cf3931afc609 > files > 3

openvpn-2.1-0.rc10.2mdv2009.0.src.rpm

diff -ur openvpn-2.1_rc10/reliable.c openvpn-2.1_rc11/reliable.c
--- openvpn-2.1_rc10/reliable.c	2008-08-10 20:35:25.000000000 +0200
+++ openvpn-2.1_rc11/reliable.c	2008-09-15 01:45:21.000000000 +0200
@@ -42,9 +42,9 @@
  * verify that test - base < extent while allowing for base or test wraparound
  */
 static inline bool
-reliable_pid_in_range (const packet_id_type test,
-		       const packet_id_type base,
-		       const unsigned int extent)
+reliable_pid_in_range1 (const packet_id_type test,
+			const packet_id_type base,
+			const unsigned int extent)
 {
   if (test >= base)
     {
@@ -52,9 +52,30 @@
 	return true;
     }
   else
-    {      
-      const packet_id_type be = base + extent;
-      if (test < be && be < base)
+    {
+      if ((test+0x80000000u) - (base+0x80000000u) < extent)
+	return true;
+    }
+
+  return false;
+}
+
+/*
+ * verify that test < base + extent while allowing for base or test wraparound
+ */
+static inline bool
+reliable_pid_in_range2 (const packet_id_type test,
+			const packet_id_type base,
+			const unsigned int extent)
+{
+  if (base + extent >= base)
+    {
+      if (test < base + extent)
+	return true;
+    }
+  else
+    {
+      if ((test+0x80000000u) < (base+0x80000000u) + extent)
 	return true;
     }
 
@@ -68,7 +89,7 @@
 reliable_pid_min (const packet_id_type p1,
 		  const packet_id_type p2)
 {
-  return !reliable_pid_in_range (p1, p2, 0x80000000);
+  return !reliable_pid_in_range1 (p1, p2, 0x80000000u);
 }
 
 /* check if a particular packet_id is present in ack */
@@ -386,7 +407,7 @@
 {
   struct gc_arena gc = gc_new ();
 
-  const int ret = reliable_pid_in_range (id, rel->packet_id, rel->size);
+  const int ret = reliable_pid_in_range2 (id, rel->packet_id, rel->size);
 
   if (!ret)
     {
@@ -441,7 +462,7 @@
 	}
     }
 
-  if (!min_id_defined || reliable_pid_in_range (rel->packet_id, min_id, rel->size))
+  if (!min_id_defined || reliable_pid_in_range1 (rel->packet_id, min_id, rel->size))
     {
       ret = reliable_get_buf (rel);
     }