From 4940b02ae016f176ca79f56d4fa4154080922d6d Mon Sep 17 00:00:00 2001 From: Michalis Kokologiannakis Date: Fri, 31 Jul 2020 11:40:27 +0300 Subject: [PATCH] build: avoid compilation warnings by using memcpy() instead of strncpy() When compiling with GCC 10.1.0 and -O2 -Wall, the strncpy() call in measured_copy() produced two stringop-truncation warnings. This addresses https://savannah.gnu.org/bugs/?58861. Signed-off-by: Michalis Kokologiannakis --- src/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.c b/src/utils.c index 98f488e8..117c2571 100644 --- a/src/utils.c +++ b/src/utils.c @@ -330,7 +330,7 @@ char *measured_copy(const char *string, size_t count) { char *thecopy = charalloc(count + 1); - strncpy(thecopy, string, count); + memcpy(thecopy, string, count); thecopy[count] = '\0'; return thecopy;