]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shorten hostname before checking for trailing dot 2763/head
authorThomas Blume <Thomas.Blume@suse.com>
Mon, 29 Feb 2016 09:19:01 +0000 (10:19 +0100)
committerThomas Blume <Thomas.Blume@suse.com>
Mon, 29 Feb 2016 09:19:01 +0000 (10:19 +0100)
Shortening can lead to a hostname that has a trailing dot.
Therefore it should be done before checking from trailing dots.

src/basic/hostname-util.c

index 3cd2f2c8721699d0165dda91f329376364c790fa..5a7ee87a20cb42f9669513a4cdb55fcbb20c52d9 100644 (file)
@@ -150,6 +150,8 @@ char* hostname_cleanup(char *s) {
 
         assert(s);
 
+        strshorten(s, HOST_NAME_MAX);
+
         for (p = s, d = s, dot = true; *p; p++) {
                 if (*p == '.') {
                         if (dot)
@@ -169,8 +171,6 @@ char* hostname_cleanup(char *s) {
         else
                 *d = 0;
 
-        strshorten(s, HOST_NAME_MAX);
-
         return s;
 }