From 32659b99982a7da03f3ba8807622ecc8dd4a0a89 Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Fri, 8 May 2015 23:25:41 +1000 Subject: [PATCH] Simplify LAMEIDENT code and remove unused variable. Replace open-coded loop with strpbrk(), make the constant lame_chars string static const and remove the unused variable 'user'. I think LAMEIDENT might be obsolete now anyway - I can't find a server that allows control chars in usernames these days. --- source/parse.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/source/parse.c b/source/parse.c index 04e5bd1..8a16bb7 100644 --- a/source/parse.c +++ b/source/parse.c @@ -1160,8 +1160,6 @@ static void p_channel(char *from, char **ArgList) if (!its_me && chan && chan->have_op) { - char lame_chars[] = "\x01\x02\x03\x04\x05\x06\x07\x08\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a"; - register char *p; if (get_cset_int_var(chan->csets, LAMELIST_CSET)) { if (lame_list && find_in_list((List **)&lame_list, from, 0)) @@ -1174,16 +1172,13 @@ static void p_channel(char *from, char **ArgList) } if (get_cset_int_var(chan->csets, LAMEIDENT_CSET)) { - for (p = FromUserHost; *p; p++) + /* This may be obsolete, I don't know of any servers that allow this */ + static const char lame_chars[] = + "\x01\x02\x03\x04\x05\x06\x07\x08\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a"; + if (strpbrk(FromUserHost, lame_chars)) { - char *user, *host; - if (!strchr(lame_chars, *p)) - continue; - user = LOCAL_COPY(FromUserHost); - host = strchr(FromUserHost, '@'); - host++; + char *host = strchr(FromUserHost, '@') + 1; send_to_server("MODE %s +b *!*@%s\r\nKICK %s %s :\002Lame Ident detected\002", chan->channel, cluster(host), chan->channel, from); - break; } } }