shared/hostname-setup: leave the terminator byte alone

gethostname(3) says it's unspecified whether the string is properly terminated
when the hostname is too long. We created a buffer with one extra byte, and it
seems the intent was to let that byte serve as terminator even if we get an
unterminated string from gethostname().
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-12-11 16:52:30 +01:00
parent b6fad30665
commit 39ede7cc37
1 changed files with 1 additions and 1 deletions

View File

@ -22,7 +22,7 @@ static int sethostname_idempotent_full(const char *s, bool really) {
assert(s);
if (gethostname(buf, sizeof(buf)) < 0)
if (gethostname(buf, sizeof(buf) - 1) < 0)
return -errno;
if (streq(buf, s))