From 1a882580340a113fd0bc8d7945f7ed949866db94 Mon Sep 17 00:00:00 2001 From: Egor Date: Sun, 8 May 2022 14:06:11 +0300 Subject: [PATCH] check channel key and member limit --- irc.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/irc.c b/irc.c index e4768b8..4cab9fa 100644 --- a/irc.c +++ b/irc.c @@ -871,7 +871,6 @@ void channel_sendnames(struct client_data *client, struct channel *chan) } void channel_join(struct client_data *client, const char *channel, const char *chankey) { - (void)chankey; // TODO: check channel limit? if (channel[0] != '#' && channel[0] != '&') return; // FIXME: error @@ -901,12 +900,16 @@ void channel_join(struct client_data *client, const char *channel, const char *c } else { if (trie_get(&chan->members, client->key)) return; - // TODO: check key - // TODO: check limit - // TODO: check ban - // TODO: check ban exemption - // TODO: check invite - // TODO: check invite exemption + if (!(client->umode & UMODE_OPER)) { + if (chan->chankey && (!chankey || strcmp(chan->chankey, chankey) == 0)) + return; // error 475 + if (chan->member_limit != -1 && chan->member_count >= chan->member_limit) + return; // error 471 + // TODO: check ban + // TODO: check ban exemption + // TODO: check invite + // TODO: check invite exemption + } } if (trie_set(&chan->members, client->key, client, NULL) == -1) abort(); -- 2.56.0