Fix memory corruption when removing certain bans from a channel.
authorMichael Poole <mdpoole@troilus.org>
Tue, 8 Feb 2005 04:42:43 +0000 (04:42 +0000)
committerMichael Poole <mdpoole@troilus.org>
Tue, 8 Feb 2005 04:42:43 +0000 (04:42 +0000)
src/proto-common.c (mod_chanmode_apply): Make sure we get a pointer to
the ban we want to deallocate BEFORE we remove it from the banlist.
git-archimport-id: srvx@srvx.net--2005-srvx/srvx--devo--1.3--patch-16

ChangeLog
src/proto-common.c

index 65d1eeb8da8b50d1338dc9ba69c7a145397a335e..24339ece9862d320937912270d2f13b1d55c4e3e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,20 @@
 # arch-tag: automatic-ChangeLog--srvx@srvx.net--2005-srvx/srvx--devo--1.3
 #
 
+2005-02-08 04:42:43 GMT        Michael Poole <mdpoole@troilus.org>     patch-16
+
+    Summary:
+      Fix memory corruption when removing certain bans from a channel.
+    Revision:
+      srvx--devo--1.3--patch-16
+
+    src/proto-common.c (mod_chanmode_apply): Make sure we get a pointer to
+    the ban we want to deallocate BEFORE we remove it from the banlist.
+
+    modified files:
+     ChangeLog src/proto-common.c
+
+
 2005-02-05 13:03:21 GMT        Michael Poole <mdpoole@troilus.org>     patch-15
 
     Summary:
index 7226977f7a01cf4871212f0b99987d6d1819d096..c740093c38edaf6b254a9c1e2f41e7a01f0bcded 100644 (file)
@@ -569,9 +569,10 @@ mod_chanmode_apply(struct userNode *who, struct chanNode *channel, struct mod_ch
              * to be more specific than an existing ban.
              */
             for (jj=0; jj<channel->banlist.used; ++jj) {
-                if (match_ircglobs(change->args[ii].u.hostmask, channel->banlist.list[jj]->ban)) {
-                    banList_remove(&channel->banlist, channel->banlist.list[jj]);
-                    free(channel->banlist.list[jj]);
+                bn = channel->banlist.list[jj];
+                if (match_ircglobs(change->args[ii].u.hostmask, bn->ban)) {
+                    banList_remove(&channel->banlist, bn);
+                    free(bn);
                     jj--;
                 }
             }
@@ -586,10 +587,11 @@ mod_chanmode_apply(struct userNode *who, struct chanNode *channel, struct mod_ch
             break;
         case MODE_REMOVE|MODE_BAN:
             for (jj=0; jj<channel->banlist.used; ++jj) {
-                if (strcmp(channel->banlist.list[jj]->ban, change->args[ii].u.hostmask))
+                bn = channel->banlist.list[jj];
+                if (strcmp(bn->ban, change->args[ii].u.hostmask))
                     continue;
-                free(channel->banlist.list[jj]);
-                banList_remove(&channel->banlist, channel->banlist.list[jj]);
+                free(bn);
+                banList_remove(&channel->banlist, bn);
                 break;
             }
             break;