1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-06 05:53:12 +02:00

Fix hardcoded ~f: and ~m: to also deal with named bans.

(Actually only made it worse by more hardcoding for now...)
This commit is contained in:
Bram Matthys
2021-08-14 10:35:15 +02:00
parent b80a9adef9
commit c7345f41b6
2 changed files with 48 additions and 18 deletions
+26
View File
@@ -372,6 +372,10 @@ int link_pre_localjoin_cb(Client *client, Channel *channel, char *parv[])
{
strlcpy(bantmp, ban->banstr + 3, sizeof(bantmp));
} else
if (!strncmp(ban->banstr, "~forward:", 9))
{
strlcpy(bantmp, ban->banstr + 9, sizeof(bantmp));
} else
if (!strncmp(ban->banstr, "~t:", 3))
{
/* A timed ban, but is it for us? Need to parse a little:
@@ -381,6 +385,28 @@ int link_pre_localjoin_cb(Client *client, Channel *channel, char *parv[])
if (p && !strncmp(p, ":~f:", 4))
{
strlcpy(bantmp, p + 4, sizeof(bantmp));
} else
if (p && !strncmp(p, ":~forward:", 10))
{
strlcpy(bantmp, p + 10, sizeof(bantmp));
} else {
/* Not for us - some other ~t ban */
continue;
}
} else
if (!strncmp(ban->banstr, "~time:", 6))
{
/* A timed ban, but is it for us? Need to parse a little:
* ~t:dddd:~f:...
*/
char *p = strchr(ban->banstr + 6, ':');
if (p && !strncmp(p, ":~f:", 4))
{
strlcpy(bantmp, p + 4, sizeof(bantmp));
} else
if (p && !strncmp(p, ":~forward:", 10))
{
strlcpy(bantmp, p + 10, sizeof(bantmp));
} else {
/* Not for us - some other ~t ban */
continue;
+22 -18
View File
@@ -88,28 +88,32 @@ int msgbypass_can_bypass(Client *client, Channel *channel, BypassChannelMessageR
for (ban = channel->exlist; ban; ban=ban->next)
{
char *type;
char *matchby;
if (!strncmp(ban->banstr, "~m:", 3))
type = ban->banstr + 3;
else if (!strncmp(ban->banstr, "~msgbypass:", 11))
type = ban->banstr + 11;
else
continue;
if (((bypass_type == BYPASS_CHANMSG_EXTERNAL) && !strncmp(type, "external:", 9)) ||
((bypass_type == BYPASS_CHANMSG_MODERATED) && !strncmp(type, "moderated:", 10)) ||
((bypass_type == BYPASS_CHANMSG_COLOR) && !strncmp(type, "color:", 6)) ||
((bypass_type == BYPASS_CHANMSG_CENSOR) && !strncmp(type, "censor:", 7)) ||
((bypass_type == BYPASS_CHANMSG_NOTICE) && !strncmp(type, "notice:", 7)))
{
char *type = ban->banstr + 3;
char *matchby;
matchby = strchr(type, ':');
if (!matchby)
continue;
matchby++;
if (((bypass_type == BYPASS_CHANMSG_EXTERNAL) && !strncmp(type, "external:", 9)) ||
((bypass_type == BYPASS_CHANMSG_MODERATED) && !strncmp(type, "moderated:", 10)) ||
((bypass_type == BYPASS_CHANMSG_COLOR) && !strncmp(type, "color:", 6)) ||
((bypass_type == BYPASS_CHANMSG_CENSOR) && !strncmp(type, "censor:", 7)) ||
((bypass_type == BYPASS_CHANMSG_NOTICE) && !strncmp(type, "notice:", 7)))
b->banstr = matchby;
if (ban_check_mask(b))
{
matchby = strchr(type, ':');
if (!matchby)
continue;
matchby++;
b->banstr = matchby;
if (ban_check_mask(b))
{
safe_free(b);
return HOOK_ALLOW; /* Yes, user may bypass */
}
safe_free(b);
return HOOK_ALLOW; /* Yes, user may bypass */
}
}
}