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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user