# HG changeset patch # User Matthew Wild # Date 1735732099 0 # Node ID 5a0e47ad7d6bd16959d6dd0bba52d9d84212a9df # Parent 64b4ede37da196b5abaf14fafdc0380761eb1027 mod_anti_spam: Gracefully handle failure to parse CIDR in IP RTBL This should prevent a traceback in case the IP address in the RTBL cannot be parsed (either due to a malformed address being published, or due to a bug in our parsing code). diff -r 64b4ede37da1 -r 5a0e47ad7d6b mod_anti_spam/mod_anti_spam.lua --- a/mod_anti_spam/mod_anti_spam.lua Wed Jan 01 09:57:31 2025 +0000 +++ b/mod_anti_spam/mod_anti_spam.lua Wed Jan 01 11:48:19 2025 +0000 @@ -125,10 +125,18 @@ }); new_rtbl_subscription(rtbl_service_jid, "spam_source_ips", { added = function (item) - spam_source_ips:add_subnet(ip.parse_cidr(item)); + local subnet_ip, subnet_bits = ip.parse_cidr(item); + if not subnet_ip then + return; + end + spam_source_ips:add_subnet(subnet_ip, subnet_bits); end; removed = function (item) - spam_source_ips:remove_subnet(ip.parse_cidr(item)); + local subnet_ip, subnet_bits = ip.parse_cidr(item); + if not subnet_ip then + return; + end + spam_source_ips:remove_subnet(subnet_ip, subnet_bits); end; }); new_rtbl_subscription(rtbl_service_jid, "spam_source_jids_sha256", {