From 092d240f6baa3b4f831192b5e2d6b880b637ee09 Mon Sep 17 00:00:00 2001 From: "geniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b" Date: Sat, 21 Apr 2007 11:50:12 +0000 Subject: [PATCH] BUILD : 1.7.18 (1238) BUGS : 662 NOTES : Fixed array count not being decremented on ChanServ access lists (provided by Jan Milants) git-svn-id: svn://svn.anope.org/anope/trunk@1238 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@957 5417fbe8-f217-4b02-8779-1006273d7864 --- Changes | 3 +++ src/core/cs_access.c | 36 +++++++++++++++++++++++++----------- src/core/cs_xop.c | 36 +++++++++++++++++++++++++----------- version.log | 6 +++++- 4 files changed, 58 insertions(+), 23 deletions(-) diff --git a/Changes b/Changes index ca72474e6..a64b856f2 100644 --- a/Changes +++ b/Changes @@ -20,6 +20,9 @@ Anope Version S V N 03/18 F Password length checking in some cases was out. [ #00] 04/21 F DefCon did not force DefCon modes while in DefCon mode. [#661] +Provided by Jan Milants - 2007 +04/21 F Array count decremention in the ChanServ access lists. [#662] + Anope Version 1.7.18 -------------------- 12/09 A Ability to see if AutoOp is enabled in NickServ INFO displays. [#621] diff --git a/src/core/cs_access.c b/src/core/cs_access.c index 1669791f7..9c52a4b9e 100644 --- a/src/core/cs_access.c +++ b/src/core/cs_access.c @@ -233,21 +233,23 @@ int do_access(User * u) } } + /* All entries should be in use so we no longer need + * to go over the entire list.. for (i = 0; i < ci->accesscount; i++) { if (!ci->access[i].in_use) break; } - if (i == ci->accesscount) { - if (i < CSAccessMax) { - ci->accesscount++; - ci->access = - srealloc(ci->access, - sizeof(ChanAccess) * ci->accesscount); - } else { - notice_lang(s_ChanServ, u, CHAN_ACCESS_REACHED_LIMIT, - CSAccessMax); - return MOD_CONT; - } + */ + + if (i < CSAccessMax) { + ci->accesscount++; + ci->access = + srealloc(ci->access, + sizeof(ChanAccess) * ci->accesscount); + } else { + notice_lang(s_ChanServ, u, CHAN_ACCESS_REACHED_LIMIT, + CSAccessMax); + return MOD_CONT; } access = &ci->access[i]; @@ -346,6 +348,18 @@ int do_access(User * u) } } } + + /* After reordering only the entries at the end could still be empty. + * We ll free the places no longer in use... */ + for (i = ci->accesscount - 1; i >= 0; i--) { + if (ci->access[i].in_use == 1) + break; + + ci->accesscount--; + } + ci->access = + srealloc(ci->access,sizeof(ChanAccess) * ci->accesscount); + /* We don't know the nick if someone used numbers, so we trigger the event without * nick param. We just do this once, even if someone enters a range. -Certus */ if (na) diff --git a/src/core/cs_xop.c b/src/core/cs_xop.c index 09eca4ce4..83cae81fe 100644 --- a/src/core/cs_xop.c +++ b/src/core/cs_xop.c @@ -301,21 +301,22 @@ int do_xop(User * u, char *xname, int xlev, int *xmsgs) } if (!change) { + /* All entries should be in use so we no longer need + * to go over the entire list.. for (i = 0; i < ci->accesscount; i++) if (!ci->access[i].in_use) break; + */ - if (i == ci->accesscount) { - if (i < CSAccessMax) { - ci->accesscount++; - ci->access = - srealloc(ci->access, - sizeof(ChanAccess) * ci->accesscount); - } else { - notice_lang(s_ChanServ, u, CHAN_XOP_REACHED_LIMIT, - CSAccessMax); - return MOD_CONT; - } + if (i < CSAccessMax) { + ci->accesscount++; + ci->access = + srealloc(ci->access, + sizeof(ChanAccess) * ci->accesscount); + } else { + notice_lang(s_ChanServ, u, CHAN_XOP_REACHED_LIMIT, + CSAccessMax); + return MOD_CONT; } access = &ci->access[i]; @@ -431,6 +432,19 @@ int do_xop(User * u, char *xname, int xlev, int *xmsgs) } } } + + /* If the patch provided in bug #706 is applied, this should be placed + * before sending the events! */ + /* After reordering only the entries at the end could still be empty. + * We ll free the places no longer in use... */ + for (i = ci->accesscount - 1; i >= 0; i--) { + if (ci->access[i].in_use == 1) + break; + + ci->accesscount--; + } + ci->access = + srealloc(ci->access,sizeof(ChanAccess) * ci->accesscount); } } else if (stricmp(cmd, "LIST") == 0) { int sent_header = 0; diff --git a/version.log b/version.log index 5c1d0afbf..30334a4b7 100644 --- a/version.log +++ b/version.log @@ -9,10 +9,14 @@ VERSION_MAJOR="1" VERSION_MINOR="7" VERSION_PATCH="18" VERSION_EXTRA="-svn" -VERSION_BUILD="1237" +VERSION_BUILD="1238" # $Log$ # +# BUILD : 1.7.18 (1238) +# BUGS : 662 +# NOTES : Fixed array count not being decremented on ChanServ access lists (provided by Jan Milants) +# # BUILD : 1.7.18 (1237) # BUGS : 661 # NOTES : Fixed DefCon which did not force DefConChanModes when it was enabled