From d0a7cefb08ce59d72b9228c0b39a07ca01acf0eb Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Sat, 15 May 2004 15:19:09 +0000 Subject: [PATCH] Forward port IPcheck bug fixes and asserts from 2.10.11. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1051 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- ChangeLog | 18 ++++++++++++++++++ ircd/IPcheck.c | 10 +++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 59f1ad4..369b403 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2004-05-15 hikari + + [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 + + [Original ChangeLog date: 2003-05-02 -MDP] + + * ircd/IPcheck.c: Added assert()'s to check for underflow + 2004-05-15 Kevin L Mitchell [Original ChangeLog date: 2003-11-22 -MDP] diff --git a/ircd/IPcheck.c b/ircd/IPcheck.c index 8e9e353..b9e69e1 100644 --- a/ircd/IPcheck.c +++ b/ircd/IPcheck.c @@ -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) { /* -- 2.20.1