From: Lennart Poettering Date: Wed, 28 Jan 2015 16:48:05 +0000 (+0100) Subject: util: add comment explaining hostname_is_valid() X-Git-Tag: v219~236 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=40672b99c7da7efd317fc31612504fe7d5ab0b65;ds=sidebyside util: add comment explaining hostname_is_valid() --- diff --git a/src/shared/util.c b/src/shared/util.c index 891182a35..11cab6dcf 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -4248,6 +4248,11 @@ bool hostname_is_valid(const char *s) { if (isempty(s)) return false; + /* Doesn't accept empty hostnames, hostnames with trailing or + * leading dots, and hostnames with multiple dots in a + * sequence. Also ensures that the length stays below + * HOST_NAME_MAX. */ + for (p = s, dot = true; *p; p++) { if (*p == '.') { if (dot)