923a60
From 0e99eafa4f0854626974db4def3e8451133578e3 Mon Sep 17 00:00:00 2001
923a60
From: Jan Synacek <jsynacek@redhat.com>
923a60
Date: Tue, 2 Oct 2018 12:36:14 +0200
923a60
Subject: [PATCH] shorten hostname before checking for trailing dot
923a60
923a60
Shortening can lead to a hostname that has a trailing dot.
923a60
Therefore it should be done before checking from trailing dots.
923a60
923a60
(cherry picked from commit 46e1a2278116e2f5067c35127ccbd8589335f734)
923a60
Resolves: #1631625
923a60
---
923a60
 src/shared/util.c | 4 ++--
923a60
 1 file changed, 2 insertions(+), 2 deletions(-)
923a60
923a60
diff --git a/src/shared/util.c b/src/shared/util.c
923a60
index c71e021cd7..4ba4693668 100644
923a60
--- a/src/shared/util.c
923a60
+++ b/src/shared/util.c
923a60
@@ -4641,6 +4641,8 @@ char* hostname_cleanup(char *s, bool lowercase) {
923a60
         char *p, *d;
923a60
         bool dot;
923a60
 
923a60
+        strshorten(s, HOST_NAME_MAX);
923a60
+
923a60
         for (p = s, d = s, dot = true; *p; p++) {
923a60
                 if (*p == '.') {
923a60
                         if (dot)
923a60
@@ -4660,8 +4662,6 @@ char* hostname_cleanup(char *s, bool lowercase) {
923a60
         else
923a60
                 *d = 0;
923a60
 
923a60
-        strshorten(s, HOST_NAME_MAX);
923a60
-
923a60
         return s;
923a60
 }
923a60