# HG changeset patch # User David A. Holland # Date 1653968872 14400 # Node ID 57b2cc9b87f72e2d8b51d18d873056c576eade2f # Parent 607e3be6bad86c78ba8221e1229010f561cdb462 Use memcpy instead of strncpy when we know the length anyway. Modern gcc seems to think it knows how to detect misuse of strncpy, but it's wrong (in fact: very, very wrong) and the path of least resistance is to not try to fight with it. diff -r 607e3be6bad8 -r 57b2cc9b87f7 anagram/agcore/stacks.cpp --- a/anagram/agcore/stacks.cpp Mon May 30 23:46:22 2022 -0400 +++ b/anagram/agcore/stacks.cpp Mon May 30 23:47:52 2022 -0400 @@ -172,7 +172,7 @@ } lcx = nc; string_base = &cs[lcx]; - strncpy(string_base,s,n); + memcpy(string_base,s,n); nc += is[ni++] = n; cs[nc] = 0; } @@ -198,7 +198,7 @@ cs = reallocate(cs,k,char); string_base = &cs[lcx]; } - strncpy(&cs[nc], s, n); + memcpy(&cs[nc], s, n); nc += n; is[ni-1] += n; cs[nc] = 0; diff -r 607e3be6bad8 -r 57b2cc9b87f7 anagram/support/agstring.cpp --- a/anagram/support/agstring.cpp Mon May 30 23:46:22 2022 -0400 +++ b/anagram/support/agstring.cpp Mon May 30 23:47:52 2022 -0400 @@ -82,7 +82,7 @@ assert(store != 0); ((short *)(void *) store)[-1] = 1; if (s) { - strncpy(store, s, k); + memcpy(store, s, k); } store[k] = 0; }