Forward port IPcheck bug fixes and asserts from 2.10.11.
authorMichael Poole <mdpoole@troilus.org>
Sat, 15 May 2004 15:19:09 +0000 (15:19 +0000)
committerMichael Poole <mdpoole@troilus.org>
Sat, 15 May 2004 15:19:09 +0000 (15:19 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1051 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
ircd/IPcheck.c

index 59f1ad40b9de90b0bff7d78cccc452ad95eb5b77..369b4031e944641ebc1864fd1954c559910892d6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2004-05-15  hikari <shadow@undernet.org>
+
+       [Original ChangeLog date: 2003-07-13 -MDP]
+       
+       * ircd/IPcheck.c: Fixed (another) overflow problem in
+       ip_registry_check_local()
+
+       [Original ChangeLog date: 2003-06-29 -MDP]
+
+       * ircd/IPcheck.c: Fixed overflow problem in
+       ip_registry_connect_fail()
+
+2004-05-15 Isomer <isomer@undernet.org>
+
+       [Original ChangeLog date: 2003-05-02 -MDP]
+       
+       * ircd/IPcheck.c: Added assert()'s to check for underflow
+
 2004-05-15  Kevin L Mitchell  <klmitch@mit.edu>
 
        [Original ChangeLog date: 2003-11-22 -MDP]
index 8e9e353201a35f869ec0d5ba5ccaf2e7b3afb033..b9e69e1d52fb1b9d6fb22ba14f4945141645f54f 100644 (file)
@@ -244,7 +244,10 @@ int ip_registry_check_local(unsigned int addr, time_t* next_target_out)
    * Don't allow more then 255 connects from one IP number, ever
    */
   if (0 == ++entry->connected)
+  {
+    entry->connected--;
     return 0;
+  }
 
   if (CONNECTED_SINCE(entry->last_connect) > IPCHECK_CLONE_PERIOD)
     entry->attempts = 0;
@@ -266,6 +269,7 @@ int ip_registry_check_local(unsigned int addr, time_t* next_target_out)
 #ifdef NOTHROTTLE 
     return 1;
 #else
+    assert(entry->connected > 0);
     --entry->connected;
     return 0;
 #endif        
@@ -337,7 +341,10 @@ void ip_registry_connect_fail(unsigned int addr)
 {
   struct IPRegistryEntry* entry = ip_registry_find(addr);
   if (entry)
-    --entry->attempts;
+  {
+    if (0 == --entry->attempts)
+      ++entry->attempts;
+  }
 }
 
 /*
@@ -392,6 +399,7 @@ void ip_registry_disconnect(struct Client *cptr)
   /*
    * If this was the last one, set `last_connect' to disconnect time (used for expiration)
    */
+  /* assert(entry->connected > 0); */
   if (0 == --entry->connected) {
     if (CONNECTED_SINCE(entry->last_connect) > IPCHECK_CLONE_LIMIT * IPCHECK_CLONE_PERIOD) {
       /*