]> diplodocus.org Git - nmh/commitdiff
mhlsbr.c: Use variable for strncpy(3)'s size, not sizeof.
authorRalph Corderoy <ralph@inputplus.co.uk>
Sun, 1 Jul 2018 08:43:05 +0000 (09:43 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Sun, 1 Jul 2018 10:12:42 +0000 (11:12 +0100)
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

index 61bf79651da00237f18c4b6499a1fd8161028d0d..86a1f41d3215a861db2d65e308d48987ad9b45b2 100644 (file)
@@ -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;