]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
rrd_rpncalc: Quiet gcc warning by copying one extra character. (#1243)
authorMichal Suchánek <msuchanek@suse.de>
Sun, 7 Jan 2024 07:50:28 +0000 (08:50 +0100)
committerGitHub <noreply@github.com>
Sun, 7 Jan 2024 07:50:28 +0000 (08:50 +0100)
gcc warns that strncpy truncates the copied string. Above the size
allocated includes space for terminating zero. Include it in the copy.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
src/rrd_rpncalc.c

index 6eef36bb44d16542f701e97d89b6bd13447aaf8f..bb923dce256a343bfc8e7a0b892b387d8282ddc5 100644 (file)
@@ -243,7 +243,7 @@ static short addop2str(
             rrd_set_error("failed to alloc memory in addop2str");
             return -1;
         }
-        strncpy(&((*result_str)[*offset]), op_str, op_len);
+        strncpy(*result_str + *offset, op_str, op_len + 1);
         *offset += op_len;
         return 1;
     }