From cbca03efe083ad2efa28b7f65c1e3232344baabc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wolfgang=20St=C3=B6ggl?= Date: Thu, 22 Aug 2019 14:18:35 +0200 Subject: [PATCH] Fix compiler warning (-Wstringop-truncation) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit - Use strncat() the following way in rrd_cgi.c: strncat(dest, src, dest_size - strlen(dest) - 1); - Fixes the following gcc compiler warning: rrd_cgi.c:1407:21: warning: ‘strncat’ output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation] strncat(line, tmp, tmplen); --- src/rrd_cgi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rrd_cgi.c b/src/rrd_cgi.c index 779b8465..35be69d6 100644 --- a/src/rrd_cgi.c +++ b/src/rrd_cgi.c @@ -1404,7 +1404,7 @@ static s_var **rrdcgiReadVariables( if ((unsigned) length > tmplen) { if ((line = (char *) realloc(line, len)) == NULL) return NULL; - strncat(line, tmp, tmplen); + strncat(line, tmp, len - strlen(line) - 1); } else { /* clean-up the storage allocated in previous iteration */ if (line) { -- 2.47.3