From af2ad7be43057a4f82dc8a223d79d68bf932ae00 Mon Sep 17 00:00:00 2001 From: Ralph Corderoy Date: Sun, 1 Jul 2018 09:43:05 +0100 Subject: [PATCH] mhlsbr.c: Use variable for strncpy(3)'s size, not sizeof. Silences gcc 8.1.1's warning that the size of the source was being used, not the destination. The destination has just been allocated to be the size of the source so no overflow can occur. Move existing variable that later holds the buffer size to before the allocation and strncpy so it can be used for those too. --- uip/mhlsbr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/uip/mhlsbr.c b/uip/mhlsbr.c index 61bf7965..86a1f41d 100644 --- a/uip/mhlsbr.c +++ b/uip/mhlsbr.c @@ -1078,8 +1078,9 @@ mhlfile (FILE *fp, char *mname, int ofilen, int ofilec) formatproc != NULL) { filterbody(c1, buf, sizeof(buf), state, gstate); } else { - holder.c_text = mh_xmalloc (sizeof(buf)); - strncpy (holder.c_text, buf, sizeof(buf)); + bufsz = sizeof buf; + holder.c_text = mh_xmalloc(bufsz); + strncpy(holder.c_text, buf, bufsz); while (state == BODY) { putcomp (c1, &holder, BODYCOMP); bufsz = sizeof buf; -- 2.56.0