[Ircservices-coding] akill sanity checking

Andy Smith andy at strugglers.net
Sat Jan 27 04:18:06 PST 2001


Hi,

There's a FIXME in the ADD section of do_akill from akill.c regarding
wanting a better way to check for an insane akill mask.  I've found the
following idea useful:

                        for (i = strlen(mask) - 1;
                             i > 0 && mask[i] != '@'; i--) {
                                if (! strchr("*?.", mask[i])) {
                                        nonwild++;
                                }
                        }

                        if (AkillWildThresh && nonwild < AkillWildThresh) {
                                notice_lang(s_OperServ, u,
                                            OPER_AKILL_MASK_TOO_GENERAL);
                                return;
                        }

i.e. it counts from right to left in the mask checking how many characters
there are which don't match '?', '*' or '.'.  AkillWildThresh would be a
config option, an example setting of 4 would prevent the following akills:

*@*
*@?*
*@*?com
*@*.com

but would allow akills such as:

*@*a.com
*@foobar*

Works for me, and is nicely configurable.

-- 
Andy Smith <andy at strugglers.net>