From 071474089bdb9ccb28f7b4a02402a09957ef8670 Mon Sep 17 00:00:00 2001 From: Cyril Jaquier Date: Sat, 23 Dec 2006 09:50:51 +0000 Subject: [PATCH] - Improved regular expression checking git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@501 a942ae1a-1317-0410-a47c-b1dcaea8d605 --- server/filter.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/server/filter.py b/server/filter.py index f19cf732..7b17397b 100644 --- a/server/filter.py +++ b/server/filter.py @@ -435,10 +435,18 @@ class Filter(JailThread): + "this format") else: try: - ipMatch = DNSUtils.textToIp(match.group("host")) - if ipMatch: - for ip in ipMatch: - failList.append([ip, date]) + matchGroup = match.group("host") + # For strange reasons, match.group can return None with some + # regular expressions. However, these expressions can be + # compiled successfully. + if matchGroup == None: + logSys.error("Unexpected error. Please correct your " + + "configuration.") + else: + ipMatch = DNSUtils.textToIp(match.group("host")) + if ipMatch: + for ip in ipMatch: + failList.append([ip, date]) except IndexError: logSys.error("There is no 'host' group in the rule. " + "Please correct your configuration.")