From: Paul Eggert Date: Mon, 13 Nov 2017 06:00:28 +0000 (-0800) Subject: timezone: pacify GCC -Wstringop-truncation X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d161b294e1267ca275352c26850255c5efc998de;p=thirdparty%2Fglibc.git timezone: pacify GCC -Wstringop-truncation Problem reported by Martin Sebor in: https://sourceware.org/ml/libc-alpha/2017-11/msg00336.html * timezone/zic.c (writezone): Use memcpy, not strncpy. (cherry picked from commit e69897bf202e18034cbef26f363bae64de70a196) --- diff --git a/ChangeLog b/ChangeLog index e2febbcce5c..9109e38a85e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2017-11-12 Paul Eggert + + timezone: pacify GCC -Wstringop-truncation + Problem reported by Martin Sebor in: + https://sourceware.org/ml/libc-alpha/2017-11/msg00336.html + * timezone/zic.c (writezone): Use memcpy, not strncpy. + 2017-11-15 Martin Sebor * misc/sys/cdefs.h (__attribute_nonstring__): New macro. diff --git a/timezone/zic.c b/timezone/zic.c index 946bf6ff8e7..e738386600c 100644 --- a/timezone/zic.c +++ b/timezone/zic.c @@ -1949,7 +1949,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);