]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
Fix compiler warning (-Wstringop-truncation)
authorWolfgang Stöggl <c72578@yahoo.de>
Thu, 22 Aug 2019 12:18:35 +0000 (14:18 +0200)
committerTobias Oetiker <tobi@oetiker.ch>
Fri, 23 Aug 2019 21:32:09 +0000 (23:32 +0200)
- 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

index 779b84652e12504d6d937d85feb54f96ef8ca45d..35be69d63532688b02203543b207bf69eb97ed41 100644 (file)
@@ -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) {