basic/hostname-util: do truncation last when cleaning up

This allows more of the original name to be used if there are invalid
chars in the beginning.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2018-12-10 09:56:56 +01:00
parent d65652f1f2
commit 5fe7a0a7de
2 changed files with 3 additions and 3 deletions
+1 -3
View File
@@ -143,9 +143,7 @@ char* hostname_cleanup(char *s) {
assert(s);
strshorten(s, HOST_NAME_MAX);
for (p = s, d = s, dot = hyphen = true; *p; p++)
for (p = s, d = s, dot = hyphen = true; *p && d - s < HOST_NAME_MAX; p++)
if (*p == '.') {
if (dot || hyphen)
continue;