From bfb6f4377d8cfc29384eec4c0bf2aeb461c69377 Mon Sep 17 00:00:00 2001 From: Philipp Spitzer Date: Wed, 5 Mar 2014 23:05:36 +0100 Subject: [PATCH] Moved hostname handling into try block to avoid an unhandled exception in case of missing hostname. --- cgi-bin/dyndns.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cgi-bin/dyndns.py b/cgi-bin/dyndns.py index b89cd39..7863b79 100755 --- a/cgi-bin/dyndns.py +++ b/cgi-bin/dyndns.py @@ -34,11 +34,6 @@ backmx = fields.getvalue('backmx') offline = fields.getvalue('offline') -# Strip zone -hostname = hostname.strip() -if hostname.endswith(ZONE): - hostname = hostname[:-len(ZONE)] - try: # check username user_info = pwd.getpwnam(username) # returns a key error if the user does not exist @@ -53,6 +48,11 @@ try: if re.match(r'[-0-9a-z]+(\.[-0-9a-z]+)*$', hostname) is None: raise RuntimeError('Invalid host name') + # strip zone + hostname = hostname.strip() + if hostname.endswith(ZONE): + hostname = hostname[:-len(ZONE)] + # check IP address ip = ipaddr.IPAddress(myip) # throws axception if the IP address is not valid if isinstance(ip, ipaddr.IPv4Address): -- 2.39.5