static int eb_extended(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type)
{
- char buf[BUFSIZE];
-
(void)chptr;
if (data == NULL)
return EXTBAN_INVALID;
- snprintf(buf, sizeof buf, "%s!%s@%s#%s",
- client_p->name, client_p->username, client_p->host, client_p->info);
+ const char *idx = strchr(data, '#');
+
+ if (idx != NULL && idx[1] == '\0')
+ /* Users cannot have empty realnames,
+ * so don't let a ban be set matching one
+ */
+ return EXTBAN_INVALID;
+
+ if (idx != NULL)
+ {
+ char buf[BUFSIZE];
+
+ // Copy the nick!user@host part of the ban
+ memcpy(buf, data, (idx - data));
+ buf[(idx - data)] = '\0';
+
+ // Advance to the realname part of the ban
+ idx++;
+
+ if (client_matches_mask(client_p, buf) && match(idx, client_p->info))
+ return EXTBAN_MATCH;
+
+ return EXTBAN_NOMATCH;
+ }
+
+ if (client_matches_mask(client_p, data))
+ return EXTBAN_MATCH;
- return match(data, buf) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
+ return EXTBAN_NOMATCH;
}