Lines 1-19
Link Here
|
1 |
--- fail2ban/server/ipdns.py.orig 2017-08-09 14:53:05 UTC |
|
|
2 |
+++ fail2ban/server/ipdns.py |
3 |
@@ -69,10 +69,14 @@ class DNSUtils: |
4 |
for fam, ipfam in ((socket.AF_INET, IPAddr.FAM_IPv4), (socket.AF_INET6, IPAddr.FAM_IPv6)): |
5 |
try: |
6 |
for result in socket.getaddrinfo(dns, None, fam, 0, socket.IPPROTO_TCP): |
7 |
- ip = IPAddr(result[4][0], ipfam) |
8 |
+ # if getaddrinfo returns something unexpected: |
9 |
+ if len(result) < 4 or not len(result[4]): continue |
10 |
+ # be sure we have an ip-string |
11 |
+ # some return an integer there |
12 |
+ ip = IPAddr(str(result[4][0]), ipfam) |
13 |
if ip.isValid: |
14 |
ips.append(ip) |
15 |
- except socket.error as e: |
16 |
+ except Exception as e: |
17 |
saveerr = e |
18 |
if not ips and saveerr: |
19 |
logSys.warning("Unable to find a corresponding IP address for %s: %s", dns, saveerr) |