From 1b8b850b054465bfca74bb862f9a2137cbdb9b6a Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Sat, 7 Jan 2006 00:54:09 +0000 Subject: [PATCH] Completely wipe out inappropriately resurrected channels. Fix off-by-one bug in convert-conf. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1605 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- ChangeLog | 8 ++++++++ ircd/convert-conf.c | 2 +- ircd/m_join.c | 37 +++++++++++++++++++++++++++++++------ 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index b105eee..9dbdc70 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-01-06 Michael Poole + + * ircd/m_join.c (ms_join): Wipe out all modes (not just chanops) + when replacing a resurrected channel. + + * ircd/convert-conf.c (dupstring): Fix probable off-by-one size + passed to memcpy(). + 2006-01-03 Michael Poole * ircd/channel.c (modebuf_flush_int): Also send timestamp when &me diff --git a/ircd/convert-conf.c b/ircd/convert-conf.c index da88adb..7947fff 100644 --- a/ircd/convert-conf.c +++ b/ircd/convert-conf.c @@ -100,7 +100,7 @@ static void simple_line(const char *block, const char **names, const char *extra fputs("};\n", stdout); } -#define dupstring(TARGET, SOURCE) do { free(TARGET); if (SOURCE) { size_t len = strlen(SOURCE); (TARGET) = malloc(len+1); memcpy((TARGET), (SOURCE), len); } else (TARGET) = 0; } while(0) +#define dupstring(TARGET, SOURCE) do { free(TARGET); if (SOURCE) { size_t len = strlen(SOURCE) + 1; (TARGET) = malloc(len); memcpy((TARGET), (SOURCE), len); } else (TARGET) = 0; } while(0) /*** MANAGING LISTS OF STRINGS ***/ diff --git a/ircd/m_join.c b/ircd/m_join.c index cec6357..e2e3e4f 100644 --- a/ircd/m_join.c +++ b/ircd/m_join.c @@ -364,7 +364,7 @@ int ms_join(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) empty (also here) and when this channel doesn't have +A set. To prevent this from allowing net-rides on the channel, we - clear all ops from the channel. + clear all modes from the channel. (Scenario for a net ride: c1 - s1 - s2 - c2, with c1 the only user in the channel; c1 parts and rejoins, gaining ops. @@ -381,17 +381,42 @@ int ms_join(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) struct ModeBuf mbuf; chptr->creationtime = creation; - /* Deop the current ops. (This will go in both directions on - * the network, and revise the channel timestamp as it goes, - * avoiding further traffic due to the JOIN.) - */ - modebuf_init(&mbuf, sptr, cptr, chptr, MODEBUF_DEST_CHANNEL | MODEBUF_DEST_HACK3 | MODEBUF_DEST_SERVER); + /* Wipe out the current modes on the channel. */ + modebuf_init(&mbuf, sptr, cptr, chptr, MODEBUF_DEST_CHANNEL | MODEBUF_DEST_HACK3); + + modebuf_mode(&mbuf, MODE_DEL | chptr->mode.mode); + chptr->mode.mode &= MODE_BURSTADDED | MODE_WASDELJOINS; + + if (chptr->mode.limit) { + modebuf_mode_uint(&mbuf, MODE_DEL | MODE_LIMIT, chptr->mode.limit); + chptr->mode.limit = 0; + } + + if (chptr->mode.key[0]) { + modebuf_mode_string(&mbuf, MODE_DEL | MODE_KEY, chptr->mode.key, 0); + chptr->mode.key[0] = '\0'; + } + + if (chptr->mode.upass[0]) { + modebuf_mode_string(&mbuf, MODE_DEL | MODE_UPASS, chptr->mode.upass, 0); + chptr->mode.upass[0] = '\0'; + } + + if (chptr->mode.apass[0]) { + modebuf_mode_string(&mbuf, MODE_DEL | MODE_APASS, chptr->mode.apass, 0); + chptr->mode.apass[0] = '\0'; + } + for (member = chptr->members; member; member = member->next_member) { if (IsChanOp(member)) { modebuf_mode_client(&mbuf, MODE_DEL | MODE_CHANOP, member->user, OpLevel(member)); member->status &= ~CHFL_CHANOP; } + if (HasVoice(member)) { + modebuf_mode_client(&mbuf, MODE_DEL | MODE_VOICE, member->user, OpLevel(member)); + member->status &= ~CHFL_VOICE; + } } modebuf_flush(&mbuf); } -- 2.20.1