From: Wolfgang Stöggl Date: Thu, 22 Aug 2019 12:18:35 +0000 (+0200) Subject: Fix compiler warning (-Wstringop-truncation) X-Git-Tag: v1.8.0~64 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=cbca03efe083ad2efa28b7f65c1e3232344baabc;p=thirdparty%2Frrdtool-1.x.git Fix compiler warning (-Wstringop-truncation) - 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); --- 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) {