From 0565882c740f1c30d8c4644a2da5db4f07c4c8bd Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Tue, 2 Apr 2019 18:50:36 +0100
Subject: [PATCH] safe_strncpy: Work around -Werror=stringop-truncation

Ideally we should bubble up errors to the caller rather than silently
truncating, but if we have to truncate, let's at least be sufficiently
explicit about it that gcc 8 doesn't sulk.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 utils/utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/utils/utils.c b/utils/utils.c
index 009d082ef..dd70f197b 100644
--- a/utils/utils.c
+++ b/utils/utils.c
@@ -169,7 +169,7 @@ find_symbol (int idx, const ElfW(Sym) *stab, size_t symsz, const char *str, size
 // way about truncation though, should probably fix that:
 char *safe_strncpy (char *dest, const char *src, size_t n)
 {
-    char *rv = strncpy( dest, src, n );
+    char *rv = strncpy( dest, src, n - 1 );
     dest[ n - 1 ] = '\0';
     return rv;
 }
-- 
GitLab