From: Ruben Kerkhof Date: Sun, 13 May 2018 15:06:54 +0000 (+0200) Subject: write_sensu: use sstrncpy X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=b34cd94ec5b8b46fb0610c020c49f20e6d3980a8;p=collectd.git write_sensu: use sstrncpy 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 --- 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 */