From f4bdf5b37dab0d9f494ccf4cbe6a5abae6fdac6d Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sun, 14 Apr 2019 21:53:35 +0200 Subject: [PATCH] fix crash / add logging for reverse lookup on invalid ip address string --- src/nsupdate/main/dnstools.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/nsupdate/main/dnstools.py b/src/nsupdate/main/dnstools.py index 431add9..fa10b3e 100644 --- a/src/nsupdate/main/dnstools.py +++ b/src/nsupdate/main/dnstools.py @@ -285,6 +285,10 @@ def rev_lookup(ipaddr): try: return socket.gethostbyaddr(ipaddr)[0] except socket.error as err: + if err.errno in (-5, 4): + # -5 / 4 == no address associated with hostname (invalid ip?) + logger.warning("errno -5 when trying to reverse lookup %r" % ipaddr) + break if err.errno in (errno.EPERM, ): # EPERM == 1 == unknown host break