- fixed broken handling of modes received from other servers.

This commit is contained in:
Alexander Barton 2002-12-16 10:52:53 +00:00
parent 865c43080a
commit 7f61f413f4
1 changed files with 116 additions and 134 deletions

View File

@ -14,7 +14,7 @@
#include "portab.h"
static char UNUSED id[] = "$Id: irc-mode.c,v 1.21 2002/12/15 16:29:18 alex Exp $";
static char UNUSED id[] = "$Id: irc-mode.c,v 1.22 2002/12/16 10:52:53 alex Exp $";
#include "imp.h"
#include <assert.h>
@ -148,16 +148,8 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
continue;
}
x[0] = '\0';
if( Client_Type( Client ) == CLIENT_SERVER )
{
/* MODE request was received from a server:
* therefore don't validate but trust it! */
x[0] = *mode_ptr;
}
else
{
/* Validate modes */
x[0] = '\0';
switch( *mode_ptr )
{
case 'i':
@ -184,10 +176,9 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
break;
default:
Log( LOG_DEBUG, "Unknown mode \"%c%c\" from \"%s\"!?", set ? '+' : '-', *mode_ptr, Client_ID( Origin ));
ok = IRC_WriteStrClient( Origin, ERR_UMODEUNKNOWNFLAG2_MSG, Client_ID( Origin ), set ? '+' : '-', *mode_ptr );
if( Client_Type( Client ) != CLIENT_SERVER ) ok = IRC_WriteStrClient( Origin, ERR_UMODEUNKNOWNFLAG2_MSG, Client_ID( Origin ), set ? '+' : '-', *mode_ptr );
x[0] = '\0';
}
}
if( ! ok ) break;
/* Is there a valid mode change? */
@ -315,17 +306,9 @@ Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel )
/* Are there arguments left? */
if( arg_arg >= Req->argc ) arg_arg = -1;
/* Validate modes */
x[0] = '\0';
client = NULL;
if( Client_Type( Client ) == CLIENT_SERVER )
{
/* MODE request was received from a server:
* therefore don't validate but trust it! */
x[0] = *mode_ptr;
}
else
{
/* Validate modes */
switch( *mode_ptr )
{
/* Channel modes */
@ -419,10 +402,9 @@ Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel )
default:
Log( LOG_DEBUG, "Unknown mode \"%c%c\" from \"%s\" on %s!?", set ? '+' : '-', *mode_ptr, Client_ID( Origin ), Channel_Name( Channel ));
ok = IRC_WriteStrClient( Origin, ERR_UMODEUNKNOWNFLAG2_MSG, Client_ID( Origin ), set ? '+' : '-', *mode_ptr );
if( Client_Type( Client ) != CLIENT_SERVER ) ok = IRC_WriteStrClient( Origin, ERR_UMODEUNKNOWNFLAG2_MSG, Client_ID( Origin ), set ? '+' : '-', *mode_ptr );
x[0] = '\0';
}
}
if( ! ok ) break;
/* Is there a valid mode change? */