0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-10-03 22:28:52 +02:00

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 ERR_MLOCKRESTRICTED 742
#define ERR_INVALIDBAN 743
#define RPL_SCANMATCHED 750
#define RPL_SCANUMODES 751

View file

@ -850,7 +850,12 @@ chm_ban(struct Client *source_p, struct Channel *chptr,
* name etc.
*/
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;
}
/* Look for a $ after the first character.
* 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 (!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;
}
}
/* 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(!ConfigChannel.use_forward)
return;
if(!check_forward(source_p, chptr, forward))
return;
/* For simplicity and future flexibility, do not
* 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;
/* Forwards only make sense for bans. */
if(mode_type != CHFL_BAN)
{
sendto_one_numeric(source_p, ERR_INVALIDBAN,
form_str(ERR_INVALIDBAN),
chptr->chname, c, raw_mask);
return;
}
}
/* 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",
/* 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",
/* 743 */ NULL,
/* 743 ERR_INVALIDBAN */ "%s %c %s :Invalid ban mask",
/* 744 */ NULL,
/* 745 */ NULL,
/* 746 */ NULL,