Skip to content

Commit

Permalink
Filter [ out of Rejecting K-Lined user snote
Browse files Browse the repository at this point in the history
This snote is generated earlier than any other snote that called
get_client_name which causes it to potentially have the wrong username
in the message. The extra [ can result in an ambiguous parse as well.
  • Loading branch information
glguy committed Jun 13, 2024
1 parent 0c59c5b commit db11156
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions ircd/s_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,23 @@ check_client(struct Client *client_p, struct Client *source_p, const char *usern
return (i);
}

/*
* Remove all occurences of needle from haystack in-place.
*
* inputs - string to filter
* - character to remove
* side effect - all occurences of needle removed from haystack
*/
static void
filter_string(char *haystack, char needle)
{
int o = 0;
for (int i = 0; haystack[i] != '\0'; i++)
if (haystack[i] != needle)
haystack[o++] = haystack[i];
haystack[o] = '\0';
}

/*
* verify_access
*
Expand Down Expand Up @@ -367,6 +384,9 @@ verify_access(struct Client *client_p, const char *username)
me.name, client_p->name,
get_user_ban_reason(aconf));

// this snote is sent before username has been cleaned
filter_string(client_p->username, '[');

sendto_realops_snomask(SNO_BANNED, L_NETWIDE,
"Rejecting K-Lined user %s [%s] (%s@%s)", get_client_name(client_p, HIDE_IP),
show_ip(NULL, client_p) ? client_p->sockhost : "255.255.255.255", aconf->user, aconf->host);
Expand Down

0 comments on commit db11156

Please sign in to comment.