summaryrefslogtreecommitdiff
path: root/src/irc/core/modes.c
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2004-07-11 14:50:47 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2004-07-11 14:50:47 +0000
commite9c3a217e3149922508c0a80d0eda8a52792d641 (patch)
treecb8a6f03f4b3ac8d0ed65065dd7954605c25d7d1 /src/irc/core/modes.c
parent84b23e20c248ab1ff83b83f888a479b9ffb59ea5 (diff)
downloadirssi-e9c3a217e3149922508c0a80d0eda8a52792d641.zip
Don't replace channel key when receiving channel mode numeric. It could be a
fake key there. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3262 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/irc/core/modes.c')
-rw-r--r--src/irc/core/modes.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/irc/core/modes.c b/src/irc/core/modes.c
index 4ef47ec0..d476d84a 100644
--- a/src/irc/core/modes.c
+++ b/src/irc/core/modes.c
@@ -288,7 +288,7 @@ void parse_channel_modes(IRC_CHANNEL_REC *channel, const char *setby,
{
IRC_SERVER_REC *server = channel->server;
GString *newmode;
- char *dup, *modestr, *arg, *curmode, type;
+ char *dup, *modestr, *arg, *curmode, type, *old_key;
int umode;
g_return_if_fail(IS_IRC_CHANNEL(channel));
@@ -296,6 +296,7 @@ void parse_channel_modes(IRC_CHANNEL_REC *channel, const char *setby,
type = '+';
newmode = g_string_new(channel->mode);
+ old_key = update_key ? NULL : g_strdup(channel->key);
dup = modestr = g_strdup(mode);
curmode = cmd_get_param(&modestr);
@@ -337,6 +338,11 @@ void parse_channel_modes(IRC_CHANNEL_REC *channel, const char *setby,
in channel modes.. */
g_free(channel->key);
channel->key = NULL;
+ } else if (!update_key) {
+ /* get the old one back, just in case it was replaced */
+ g_free(channel->key);
+ channel->key = old_key;
+ old_key = NULL;
}
if (strcmp(newmode->str, channel->mode) != 0) {
@@ -347,6 +353,7 @@ void parse_channel_modes(IRC_CHANNEL_REC *channel, const char *setby,
}
g_string_free(newmode, TRUE);
+ g_free(old_key);
}
/* add `mode' to `old' - return newly allocated mode.