From da71e7473ce7a454170d3030f2edcd1c1b1e04d4 Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Tue, 8 Feb 2005 04:42:43 +0000 Subject: [PATCH] Fix memory corruption when removing certain bans from a channel. 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 | 14 ++++++++++++++ src/proto-common.c | 14 ++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 65d1eeb..24339ec 100644 --- 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 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 patch-15 Summary: diff --git a/src/proto-common.c b/src/proto-common.c index 7226977..c740093 100644 --- a/src/proto-common.c +++ b/src/proto-common.c @@ -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; jjbanlist.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; jjbanlist.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; -- 2.20.1