X-Git-Url: https://jfr.im/git/solanum.git/blobdiff_plain/9b24cbdecc72337e825764f39cdf59ca23f41788..67ab06dd8a4c6840fcba129891cd9096543a0478:/modules/m_kline.c diff --git a/modules/m_kline.c b/modules/m_kline.c index 7c55fc55..0b1d0bf3 100644 --- a/modules/m_kline.c +++ b/modules/m_kline.c @@ -85,6 +85,7 @@ static void remove_permkline_match(struct Client *, struct ConfItem *); static bool remove_temp_kline(struct Client *, struct ConfItem *); static void remove_prop_kline(struct Client *, struct ConfItem *); + /* mo_kline() * * parv[1] - temp time or user@host @@ -98,7 +99,7 @@ mo_kline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source { char def[] = "No Reason"; char user[USERLEN + 2]; - char host[HOSTLEN + 2]; + char host_buf[HOSTLEN + 3], *host = host_buf + 1; char *reason = def; char *oper_reason; const char *target_server = NULL; @@ -122,6 +123,12 @@ mo_kline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source if(find_user_host(source_p, parv[loc], user, host) == 0) return; + if (*host == ':') + { + host--; + *host = '0'; + } + loc++; if(parc >= loc + 2 && !irccmp(parv[loc], "ON")) @@ -146,6 +153,14 @@ mo_kline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source reason = LOCAL_COPY(parv[loc]); + if(parse_netmask_strict(host, NULL, NULL) == HM_ERROR) + { + sendto_one_notice(source_p, + ":[%s@%s] looks like an ill-formed IP K-line, refusing to set it", + user, host); + return; + } + if(target_server != NULL) { propagate_generic(source_p, "KLINE", target_server, CAP_KLN, @@ -215,17 +230,7 @@ mo_kline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source else apply_kline(source_p, aconf, reason, oper_reason); - if(ConfigFileEntry.kline_delay) - { - if(!kline_queued) - { - rb_event_addonce("check_klines", check_klines_event, NULL, - ConfigFileEntry.kline_delay); - kline_queued = true; - } - } - else - check_klines(); + check_one_kline(aconf); } /* ms_kline() @@ -325,17 +330,7 @@ handle_remote_kline(struct Client *source_p, int tkline_time, else apply_kline(source_p, aconf, reason, oper_reason); - if(ConfigFileEntry.kline_delay) - { - if(!kline_queued) - { - rb_event_addonce("check_klines", check_klines_event, NULL, - ConfigFileEntry.kline_delay); - kline_queued = true; - } - } - else - check_klines(); + check_one_kline(aconf); } /* mo_unkline() @@ -713,17 +708,12 @@ already_placed_kline(struct Client *source_p, const char *luser, const char *lho if(aconf == NULL && ConfigFileEntry.non_redundant_klines) { bits = 0; - if((t = parse_netmask(lhost, &iphost, &bits)) != HM_HOST) - { -#ifdef RB_IPV6 - if(t == HM_IPV6) - t = AF_INET6; - else -#endif - t = AF_INET; - - piphost = &iphost; - } + t = parse_netmask_strict(lhost, &iphost, &bits); + piphost = &iphost; + if (t == HM_IPV4) + t = AF_INET; + else if (t == HM_IPV6) + t = AF_INET6; else piphost = NULL;