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