From f1d38f20f760376f43b90a105486cf3ff2fbf2c4 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 21 Jan 2006 23:23:58 +0100 Subject: Fixed counting of arguments in i[rp]c_exec(), made them a bit too simple. --- ipc.c | 10 ++++++++-- irc_commands.c | 7 +++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ipc.c b/ipc.c index 8d44e4eb..3528988f 100644 --- a/ipc.c +++ b/ipc.c @@ -154,7 +154,7 @@ static const command_t ipc_child_commands[] = { static void ipc_command_exec( void *data, char **cmd, const command_t *commands ) { - int i; + int i, j; if( !cmd[0] ) return; @@ -162,12 +162,18 @@ static void ipc_command_exec( void *data, char **cmd, const command_t *commands for( i = 0; commands[i].command; i ++ ) if( g_strcasecmp( commands[i].command, cmd[0] ) == 0 ) { + /* There is no typo in this line: */ + for( j = 1; cmd[j]; j ++ ); j --; + + if( j < commands[i].required_parameters ) + break; + if( commands[i].flags & IPC_CMD_TO_CHILDREN ) ipc_to_children( cmd ); else commands[i].execute( data, cmd ); - return; + break; } } diff --git a/irc_commands.c b/irc_commands.c index e4dc4f3e..9e47b83b 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -578,7 +578,7 @@ static const command_t irc_commands[] = { void irc_exec( irc_t *irc, char *cmd[] ) { - int i; + int i, n_arg; if( !cmd[0] ) return; @@ -586,6 +586,9 @@ void irc_exec( irc_t *irc, char *cmd[] ) for( i = 0; irc_commands[i].command; i++ ) if( g_strcasecmp( irc_commands[i].command, cmd[0] ) == 0 ) { + /* There should be no typo in the next line: */ + for( n_arg = 0; cmd[n_arg]; n_arg ++ ); n_arg --; + if( irc_commands[i].flags & IRC_CMD_PRE_LOGIN && irc->status >= USTATUS_LOGGED_IN ) { irc_reply( irc, 462, ":Only allowed before logging in" ); @@ -598,7 +601,7 @@ void irc_exec( irc_t *irc, char *cmd[] ) { irc_reply( irc, 481, ":Permission denied - You're not an IRC operator" ); } - else if( !cmd[irc_commands[i].required_parameters] ) + else if( n_arg < irc_commands[i].required_parameters ) { irc_reply( irc, 461, "%s :Need more parameters", cmd[0] ); } -- cgit v1.2.3