From: Roy Marples Date: Tue, 13 Jun 2017 21:01:58 +0000 (+0100) Subject: RFC2181 section 11 says a DNS label can be pretty much anything. X-Git-Tag: v7.0.0-rc2~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4bd8b04d7cc34f61088ae511015d7729aa972c0c;p=thirdparty%2Fdhcpcd.git RFC2181 section 11 says a DNS label can be pretty much anything. So just test overall length and label length. Thanks to Robert Elz. --- diff --git a/hooks/dhcpcd-run-hooks.in b/hooks/dhcpcd-run-hooks.in index 076ffb2b..6c37bde6 100644 --- a/hooks/dhcpcd-run-hooks.in +++ b/hooks/dhcpcd-run-hooks.in @@ -198,8 +198,7 @@ syslog() fi } -# Check for a valid domain name as per RFC1123 with the exception of -# allowing - and _ as they seem to be widely used. +# Check for a valid domain name as per RFC2181 section 11 valid_domainname() { local name="$1" label @@ -209,11 +208,7 @@ valid_domainname() while [ -n "$name" ]; do label="${name%%.*}" [ -z "$label" -o ${#label} -gt 63 ] && return 1 - case "$label" in - -*|_*|*-|*_) return 1;; - *[![:alnum:]_-]*) return 1;; - "$name") return 0;; - esac + [ "$label" = "$name" ] && return 0 name="${name#*.}" done return 0