valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

Blame SOURCES/0695-shorten-hostname-before-checking-for-trailing-dot.patch

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