From 49cdd6bf09932d518914340ceeda59ce68f9c217 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Wed, 20 Jun 2018 12:27:59 +0200 Subject: [PATCH] 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. --- reference.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/reference.c b/reference.c index dbc40e7..0ae7ab2 100644 --- a/reference.c +++ b/reference.c @@ -545,6 +545,8 @@ maybe_log_offset(double offset, time_t now) if (gethostname(host, sizeof(host)) < 0) { strcpy(host, ""); } + host[sizeof (host) - 1] = '\0'; + fprintf(p, "Subject: chronyd reports change to system clock on node [%s]\n", host); fputs("\n", p);