mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
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:
parent
b6fad30665
commit
39ede7cc37
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user