diff options
| author | Roy Marples <roy@marples.name> | 2017-06-13 22:01:58 +0100 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2017-06-13 22:02:55 +0100 |
| commit | 6da580eefb0d94d1b377303e84af821556ab33b0 (patch) | |
| tree | 992321da91d5a5301d74b7660b0c3b8e0237b909 /hooks | |
| parent | 6b068a4357a1f6644b4748cdf72edd280f73f135 (diff) | |
| download | dhcpcd-6da580eefb0d94d1b377303e84af821556ab33b0.tar.xz | |
RFC2181 section 11 says a DNS label can be pretty much anything.
So just test overall length and label length.
Thanks to Robert Elz.
Diffstat (limited to 'hooks')
| -rw-r--r-- | hooks/dhcpcd-run-hooks.in | 9 |
1 files changed, 2 insertions, 7 deletions
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 |
