Commit 7abb69b5 authored by Simon Kelley's avatar Simon Kelley

Tighten checks in legal_hostname().

parent d5052fb2
...@@ -142,19 +142,23 @@ static int check_name(char *in) ...@@ -142,19 +142,23 @@ static int check_name(char *in)
int legal_hostname(char *name) int legal_hostname(char *name)
{ {
char c; char c;
int first;
if (!check_name(name)) if (!check_name(name))
return 0; return 0;
for (; (c = *name); name++) for (first = 1; (c = *name); name++, first = 0)
/* check for legal char a-z A-Z 0-9 - _ . */ /* check for legal char a-z A-Z 0-9 - _ . */
{ {
if ((c >= 'A' && c <= 'Z') || if ((c >= 'A' && c <= 'Z') ||
(c >= 'a' && c <= 'z') || (c >= 'a' && c <= 'z'))
(c >= '0' && c <= '9') ||
c == '-' || c == '_')
continue; continue;
if (!first &&
((c >= '0' && c <= '9') ||
c == '-' || c == '_'))
continue;
/* end of hostname part */ /* end of hostname part */
if (c == '.') if (c == '.')
return 1; return 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment