Avoid -Wstringop-truncation.
authorMartin Sebor <msebor@redhat.com>
Mon, 1 Feb 2021 15:58:31 +0000 (08:58 -0700)
committerMartin Sebor <msebor@redhat.com>
Mon, 1 Feb 2021 16:00:02 +0000 (09:00 -0700)
libiberty/ChangeLog:

* dyn-string.c (dyn_string_insert_cstr): Use memcpy instead of strncpy
to avoid -Wstringop-truncation.

libiberty/dyn-string.c

index ea71118..8d2456b 100644 (file)
@@ -277,7 +277,7 @@ dyn_string_insert_cstr (dyn_string_t dest, int pos, const char *src)
   for (i = dest->length; i >= pos; --i)
     dest->s[i + length] = dest->s[i];
   /* Splice in the new stuff.  */
-  strncpy (dest->s + pos, src, length);
+  memcpy (dest->s + pos, src, length);
   /* Compute the new length.  */
   dest->length += length;
   return 1;