From 641f2c48b10dec5ab6dd90f560b66e061aa660ba Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 12 Nov 2017 00:57:19 -0800 Subject: [PROPOSED] Port to GCC 8 -Wstringop-truncation Problem reported by Martin Sebor in: https://sourceware.org/ml/libc-alpha/2017-11/msg00336.html * NEWS: Mention this. * zic.c (writezone): Use memcpy, not strncpy. --- NEWS | 3 +++ zic.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 966f9b6..7881936 100644 --- a/NEWS +++ b/NEWS @@ -29,6 +29,9 @@ Unreleased, experimental changes Diagnostics and commentary now distinguish UT from UTC more carefully; see theory.html for more information about UT vs UTC. + zic has been ported to GCC 8's -Wstringop-truncation option. + (Problem reported by Martin Sebor.) + Release 2017c - 2017-10-20 14:49:34 -0700 diff --git a/zic.c b/zic.c index 82e653d..e36301f 100644 --- a/zic.c +++ b/zic.c @@ -1960,7 +1960,7 @@ writezone(const char *const name, const char *const string, char version) } #define DO(field) fwrite(tzh.field, sizeof tzh.field, 1, fp) tzh = tzh0; - strncpy(tzh.tzh_magic, TZ_MAGIC, sizeof tzh.tzh_magic); + memcpy(tzh.tzh_magic, TZ_MAGIC, sizeof tzh.tzh_magic); tzh.tzh_version[0] = version; convert(thistypecnt, tzh.tzh_ttisgmtcnt); convert(thistypecnt, tzh.tzh_ttisstdcnt); -- 2.7.4