From: Miroslav Lichvar Date: Wed, 20 Jun 2018 10:27:59 +0000 (+0200) Subject: reference: terminate string returned by gethostname() X-Git-Tag: 3.4-pre1~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49cdd6bf09932d518914340ceeda59ce68f9c217;p=thirdparty%2Fchrony.git 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. --- diff --git a/reference.c b/reference.c index dbc40e70..0ae7ab2d 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);