Add an error message if a ban mask is invalid.

This is given if the ban mask is too long, it is an invalid extban or the
forward channel is invalid and no other message has been given about that.
This commit is contained in:
Jilles Tjoelker 2011-12-18 23:24:22 +01:00
parent f2edb2be59
commit be0365e152
3 changed files with 27 additions and 7 deletions

View file

@ -365,6 +365,7 @@ extern const char *form_str(int);
#define RPL_ENDOFRSACHALLENGE2 741 #define RPL_ENDOFRSACHALLENGE2 741
#define ERR_MLOCKRESTRICTED 742 #define ERR_MLOCKRESTRICTED 742
#define ERR_INVALIDBAN 743
#define RPL_SCANMATCHED 750 #define RPL_SCANMATCHED 750
#define RPL_SCANUMODES 751 #define RPL_SCANUMODES 751

View file

@ -850,7 +850,12 @@ chm_ban(struct Client *source_p, struct Channel *chptr,
* name etc. * name etc.
*/ */
if(strlen(mask) > IRCD_MIN(BANLEN, MODEBUFLEN - 5)) if(strlen(mask) > IRCD_MIN(BANLEN, MODEBUFLEN - 5))
{
sendto_one_numeric(source_p, ERR_INVALIDBAN,
form_str(ERR_INVALIDBAN),
chptr->chname, c, raw_mask);
return; return;
}
/* Look for a $ after the first character. /* Look for a $ after the first character.
* As the first character, it marks an extban; afterwards * As the first character, it marks an extban; afterwards
@ -869,8 +874,12 @@ chm_ban(struct Client *source_p, struct Channel *chptr,
if (*mask == '$' && MyClient(source_p)) if (*mask == '$' && MyClient(source_p))
{ {
if (!valid_extban(mask, source_p, chptr, mode_type)) if (!valid_extban(mask, source_p, chptr, mode_type))
/* XXX perhaps return an error message here */ {
sendto_one_numeric(source_p, ERR_INVALIDBAN,
form_str(ERR_INVALIDBAN),
chptr->chname, c, raw_mask);
return; return;
}
} }
/* For compatibility, only check the forward channel from /* For compatibility, only check the forward channel from
@ -878,18 +887,28 @@ chm_ban(struct Client *source_p, struct Channel *chptr,
*/ */
if(forward != NULL && MyClient(source_p)) if(forward != NULL && MyClient(source_p))
{ {
if(!ConfigChannel.use_forward)
return;
if(!check_forward(source_p, chptr, forward))
return;
/* For simplicity and future flexibility, do not /* For simplicity and future flexibility, do not
* allow '$' in forwarding targets. * allow '$' in forwarding targets.
*/ */
if(strchr(forward, '$') != NULL) if(!ConfigChannel.use_forward ||
strchr(forward, '$') != NULL)
{
sendto_one_numeric(source_p, ERR_INVALIDBAN,
form_str(ERR_INVALIDBAN),
chptr->chname, c, raw_mask);
return;
}
/* check_forward() sends its own error message */
if(!check_forward(source_p, chptr, forward))
return; return;
/* Forwards only make sense for bans. */ /* Forwards only make sense for bans. */
if(mode_type != CHFL_BAN) if(mode_type != CHFL_BAN)
{
sendto_one_numeric(source_p, ERR_INVALIDBAN,
form_str(ERR_INVALIDBAN),
chptr->chname, c, raw_mask);
return; return;
}
} }
/* dont allow local clients to overflow the banlist, dont /* dont allow local clients to overflow the banlist, dont

View file

@ -768,7 +768,7 @@ static const char * replies[] = {
/* 740 RPL_RSACHALLENGE2*/ ":%s 740 %s :%s", /* 740 RPL_RSACHALLENGE2*/ ":%s 740 %s :%s",
/* 741 RPL_ENDOFRSACHALLENGE2*/ ":%s 741 %s :End of CHALLENGE", /* 741 RPL_ENDOFRSACHALLENGE2*/ ":%s 741 %s :End of CHALLENGE",
/* 742 ERR_MLOCKRESTRICTED */ "%s %c %s :MODE cannot be set due to channel having an active MLOCK restriction policy", /* 742 ERR_MLOCKRESTRICTED */ "%s %c %s :MODE cannot be set due to channel having an active MLOCK restriction policy",
/* 743 */ NULL, /* 743 ERR_INVALIDBAN */ "%s %c %s :Invalid ban mask",
/* 744 */ NULL, /* 744 */ NULL,
/* 745 */ NULL, /* 745 */ NULL,
/* 746 */ NULL, /* 746 */ NULL,