mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 17:45:07 -05:00
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:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user