reference: terminate string returned by gethostname()
POSIX doesn't require the string to be terminated if it didn't fit in the buffer. This issue was found in a Frama-C analysis.
This commit is contained in:
parent
63fe34e890
commit
49cdd6bf09
1 changed files with 2 additions and 0 deletions
|
@ -545,6 +545,8 @@ maybe_log_offset(double offset, time_t now)
|
|||
if (gethostname(host, sizeof(host)) < 0) {
|
||||
strcpy(host, "<UNKNOWN>");
|
||||
}
|
||||
host[sizeof (host) - 1] = '\0';
|
||||
|
||||
fprintf(p, "Subject: chronyd reports change to system clock on node [%s]\n", host);
|
||||
fputs("\n", p);
|
||||
|
||||
|
|
Loading…
Reference in a new issue