Also add 476 response.
Also move that stuff out of config.h. This isn't something that should
be configured at compile time.
struct tls;
#endif
+#define MAX_NICKLEN 32
+#define MAX_CHANLEN 33
#define MONITOR_LIMIT 100
#define SETBIT(var, bit, val) ((void)((val) ? ((var)|=(bit)) : ((var)&=~(bit))))
-#define MAX_NICKLEN 32
#ifndef ADMINLOC1
#define ADMINLOC1 "Location 1"
#endif
{
// TODO: check channel limit?
if (channel[0] != '#' && channel[0] != '&')
- return; // FIXME: error
+ return err_badchanmask(client, channel), sendbuf(client);
if (strchr(channel, '\7') || strchr(channel, ' ') || strchr(channel, ','))
- return; // FIXME: error
+ return err_badchanmask(client, channel), sendbuf(client);
size_t chanlen = strlen(channel);
- if (chanlen > 32)
- return; // FIXME: error
- char key[33];
+ if (chanlen >= MAX_CHANLEN)
+ return err_badchanmask(client, channel), sendbuf(client);
+ char key[MAX_CHANLEN];
memcpy(key, channel, chanlen+1);
stringlower(key);
struct channel *chan = channel_map.get(key);
struct channel *findChannel(const char *channel)
{
size_t chanlen = strlen(channel);
- if (chanlen > 32)
+ if (chanlen >= MAX_CHANLEN)
return NULL;
- char key[33];
+ char key[MAX_CHANLEN];
memcpy(key, channel, chanlen+1);
stringlower(key);
return channel_map.get(key);
}
void rpl_isupport(struct client_data *client) // 005
{
- copy_strf(&databuf, ":%s 005 %s NETWORK=PatchyIRC CASEMAPPING=ascii NICKLEN=%u EXCEPTS=e INVEX=I MAXTARGETS=1 CHANMODES=beIqw,k,l,Pimnst CHANTYPES=#& PREFIX=(ov)@+ STATUSMSG=@+ BOT=B WHOX MONITOR=%u :are supported by this server\r\n", hostname, client->nick, MAX_NICKLEN-1, MONITOR_LIMIT);
+ copy_strf(&databuf, ":%s 005 %s NETWORK=PatchyIRC CASEMAPPING=ascii NICKLEN=%u CHANNELLEN=%u EXCEPTS=e INVEX=I MAXTARGETS=1 CHANMODES=beIqw,k,l,Pimnst CHANTYPES=#& PREFIX=(ov)@+ STATUSMSG=@+ BOT=B WHOX MONITOR=%u :are supported by this server\r\n", hostname, client->nick, MAX_NICKLEN-1, MAX_CHANLEN-1, MONITOR_LIMIT);
}
#if 0
{
copy_strf(&databuf, ":%s 475 %s %s :Cannot join channel (+k)\r\n", hostname, client->nick, chan->name);
}
-// 476 ERR_BADCHANMASK
+void err_badchanmask(struct client_data *client, const char *channel) // 476
+{
+ copy_strf(&databuf, ":%s 476 %s :Bad Channel Mask\r\n", hostname, client->nick, channel);
+}
void err_noprivileges(struct client_data *client) // 481
{
copy_strf(&databuf, ":%s 481 %s :Permission Denied- You're not an IRC operator\r\n", hostname, client->nick);
void err_inviteonlychan(struct client_data *client, struct channel *chan); // 473
void err_bannedfromchan(struct client_data *client, struct channel *chan); // 474
void err_badchannelkey(struct client_data *client, struct channel *chan); // 475
-// 476 ERR_BADCHANMASK
+void err_badchanmask(struct client_data *client, const char *channel); // 476
void err_noprivileges(struct client_data *client); // 481
void err_chanoprivsneeded(struct client_data *client, struct channel *chan); // 481
// 483 ERR_CANTKILLSERVER