From b34cd94ec5b8b46fb0610c020c49f20e6d3980a8 Mon Sep 17 00:00:00 2001 From: Ruben Kerkhof Date: Sun, 13 May 2018 17:06:54 +0200 Subject: [PATCH] write_sensu: use sstrncpy MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fixes: CC src/write_sensu.lo src/write_sensu.c: In function ‘replace_str’: src/write_sensu.c:630:3: warning: ‘strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation] strncpy(r, p, strlen(p)); ^~~~~~~~~~~~~~~~~~~~~~~~ CCLD write_sensu.la --- src/write_sensu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/write_sensu.c b/src/write_sensu.c index 71dd5854..a9f621d7 100644 --- a/src/write_sensu.c +++ b/src/write_sensu.c @@ -627,7 +627,7 @@ static char *replace_str(const char *str, const char *old, /* {{{ */ r += newlen; p = q + oldlen; } - strncpy(r, p, strlen(p)); + sstrncpy(r, p, sizeof(r)); return ret; } /* }}} char *replace_str */ -- 2.11.0