From b8a3e3a2c7bb637c93173cf8f8970cc83657cb94 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sun, 18 Nov 2018 20:48:26 +0100 Subject: [PATCH] avoid invalid IP address crash, fixes #394 --- nsupdate/api/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nsupdate/api/views.py b/nsupdate/api/views.py index 183836b..8dd0f6f 100644 --- a/nsupdate/api/views.py +++ b/nsupdate/api/views.py @@ -343,7 +343,8 @@ def _update_or_delete(host, ipaddr, secure=False, logger=None, _delete=False): ipaddr = str(ipaddr) kind = check_ip(ipaddr, ('ipv4', 'ipv6')) rdtype = 'A' if kind == 'ipv4' else 'AAAA' - except (ValueError, UnicodeError): + IPNetwork(ipaddr) # raise AddrFormatError here if there is an issue with ipaddr, see #394 + except (ValueError, UnicodeError, AddrFormatError): # invalid ip address string # some people manage to even give a non-ascii string instead of an ip addr msg = '%s - received bad ip address: %r' % (fqdn, ipaddr)