From bcb45da1b416e7ee4b50dcf16947fb9703f713cf Mon Sep 17 00:00:00 2001 From: "Federico G. Schwindt" Date: Thu, 5 Sep 2013 17:11:38 +0100 Subject: [PATCH] Add more penalty times Ensure before every numeric 461 there is a call to IRC_SetPenalty(). --- src/ngircd/irc-channel.c | 12 +++++++++--- src/ngircd/irc-info.c | 4 +++- src/ngircd/irc-login.c | 5 ++++- src/ngircd/irc-mode.c | 3 +++ src/ngircd/irc-op.c | 1 + src/ngircd/irc-oper.c | 12 +++++++++--- src/ngircd/irc-server.c | 12 +++++++++--- src/ngircd/irc.c | 1 + 8 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/ngircd/irc-channel.c b/src/ngircd/irc-channel.c index ce042043..d5e7bdd1 100644 --- a/src/ngircd/irc-channel.c +++ b/src/ngircd/irc-channel.c @@ -323,9 +323,11 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req ) channame = strtok_r(channame, ",", &lastchan); /* Make sure that "channame" is not the empty string ("JOIN :") */ - if (! channame) + if (!channame) { + IRC_SetPenalty(Client, 2); return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command); + } while (channame) { flags = NULL; @@ -445,9 +447,11 @@ IRC_PART(CLIENT * Client, REQUEST * Req) chan = strtok(Req->argv[0], ","); /* Make sure that "chan" is not the empty string ("PART :") */ - if (! chan) + if (!chan) { + IRC_SetPenalty(Client, 2); return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command); + } while (chan) { Channel_Part(target, Client, chan, @@ -662,9 +666,11 @@ IRC_CHANINFO( CLIENT *Client, REQUEST *Req ) assert( Req != NULL ); /* Bad number of parameters? */ - if (Req->argc < 2 || Req->argc == 4 || Req->argc > 5) + if (Req->argc < 2 || Req->argc == 4 || Req->argc > 5) { + IRC_SetPenalty(Client, 2); return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command); + } /* Compatibility kludge */ if (Req->argc == 5) diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c index 88455c74..1c250a44 100644 --- a/src/ngircd/irc-info.c +++ b/src/ngircd/irc-info.c @@ -1146,11 +1146,13 @@ IRC_WHO(CLIENT *Client, REQUEST *Req) if (strcmp(Req->argv[1], "o") == 0) only_ops = true; #ifdef STRICT_RFC - else + else { + IRC_SetPenalty(Client, 2); return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command); + } #endif } diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c index 67a0fbfd..013481d2 100644 --- a/src/ngircd/irc-login.c +++ b/src/ngircd/irc-login.c @@ -81,6 +81,7 @@ IRC_PASS( CLIENT *Client, REQUEST *Req ) } else if (Client_Type(Client) == CLIENT_UNKNOWN || Client_Type(Client) == CLIENT_UNKNOWNSERVER) { /* Unregistered connection, but wrong number of arguments: */ + IRC_SetPenalty(Client, 2); return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command); } else { @@ -270,9 +271,11 @@ IRC_NICK( CLIENT *Client, REQUEST *Req ) /* Server or service introduces new client */ /* Bad number of parameters? */ - if (Req->argc != 2 && Req->argc != 7) + if (Req->argc != 2 && Req->argc != 7) { + IRC_SetPenalty(Client, 2); return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command); + } if (Req->argc >= 7) { /* RFC 2813 compatible syntax */ diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c index 38fec0d0..e2fa59a2 100644 --- a/src/ngircd/irc-mode.c +++ b/src/ngircd/irc-mode.c @@ -622,6 +622,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel) #ifdef STRICT_RFC /* Only send error message in "strict" mode, * this is how ircd2.11 and others behave ... */ + IRC_SetPenalty(Origin, 2); connected = IRC_WriteErrClient(Origin, ERR_NEEDMOREPARAMS_MSG, Client_ID(Origin), Req->command); @@ -666,6 +667,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel) #ifdef STRICT_RFC /* Only send error message in "strict" mode, * this is how ircd2.11 and others behave ... */ + IRC_SetPenalty(Origin, 2); connected = IRC_WriteErrClient(Origin, ERR_NEEDMOREPARAMS_MSG, Client_ID(Origin), Req->command); @@ -767,6 +769,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel) * mode, because most other servers don't do * it as well and some clients send "wired" * MODE commands like "MODE #chan -ooo nick". */ + IRC_SetPenalty(Origin, 2); connected = IRC_WriteErrClient(Origin, ERR_NEEDMOREPARAMS_MSG, Client_ID(Origin), Req->command); diff --git a/src/ngircd/irc-op.c b/src/ngircd/irc-op.c index 23db579e..52126877 100644 --- a/src/ngircd/irc-op.c +++ b/src/ngircd/irc-op.c @@ -122,6 +122,7 @@ IRC_KICK(CLIENT *Client, REQUEST *Req) nickCount--; } } else { + IRC_SetPenalty(Client, 2); return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command); } diff --git a/src/ngircd/irc-oper.c b/src/ngircd/irc-oper.c index 40633177..4d17085f 100644 --- a/src/ngircd/irc-oper.c +++ b/src/ngircd/irc-oper.c @@ -208,14 +208,18 @@ IRC_CONNECT(CLIENT * Client, REQUEST * Req) /* Bad number of parameters? */ if (Req->argc != 1 && Req->argc != 2 && Req->argc != 3 && - Req->argc != 5 && Req->argc != 6) + Req->argc != 5 && Req->argc != 6) { + IRC_SetPenalty(Client, 2); return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command); + } /* Invalid port number? */ - if ((Req->argc > 1) && atoi(Req->argv[1]) < 1) + if ((Req->argc > 1) && atoi(Req->argv[1]) < 1) { + IRC_SetPenalty(Client, 2); return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command); + } if (Client_Type(Client) != CLIENT_SERVER && !Client_HasMode(Client, 'o')) @@ -391,9 +395,11 @@ IRC_xLINE(CLIENT *Client, REQUEST *Req) assert(Req != NULL); /* Bad number of parameters? */ - if (Req->argc != 1 && Req->argc != 3) + if (Req->argc != 1 && Req->argc != 3) { + IRC_SetPenalty(Client, 2); return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command); + } from = Op_Check(Client, Req); if (!from) diff --git a/src/ngircd/irc-server.c b/src/ngircd/irc-server.c index 80bb6a61..030c3cd1 100644 --- a/src/ngircd/irc-server.c +++ b/src/ngircd/irc-server.c @@ -72,10 +72,12 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req ) LogDebug("Connection %d: got SERVER command (new server link) ...", Client_Conn(Client)); - if (Req->argc != 2 && Req->argc != 3) + if (Req->argc != 2 && Req->argc != 3) { + IRC_SetPenalty(Client, 2); return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command); + } /* Get configuration index of new remote server ... */ for (i = 0; i < MAX_SERVERS; i++) @@ -183,9 +185,11 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req ) { /* New server is being introduced to the network */ - if (Req->argc != 4) + if (Req->argc != 4) { + IRC_SetPenalty(Client, 2); return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command); + } /* check for existing server with same ID */ if (!Client_CheckID(Client, Req->argv[0])) @@ -231,9 +235,11 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req ) Client_MyToken(c), Client_Info(c)); return CONNECTED; - } else + } else { + IRC_SetPenalty(Client, 2); return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command); + } } /* IRC_SERVER */ /* diff --git a/src/ngircd/irc.c b/src/ngircd/irc.c index 7dafaf05..d41439ed 100644 --- a/src/ngircd/irc.c +++ b/src/ngircd/irc.c @@ -510,6 +510,7 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors) if (Req->argc > 2) { if (!SendErrors) return CONNECTED; + IRC_SetPenalty(Client, 2); return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command); } -- 2.39.2