From e9c3a217e3149922508c0a80d0eda8a52792d641 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sun, 11 Jul 2004 14:50:47 +0000 Subject: 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 --- src/irc/core/modes.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/irc/core') 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. -- cgit v1.2.3