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