From f71361877db9208f9b00dfe81e9c85a8b4f16ca8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Such=C3=A1nek?= Date: Sun, 7 Jan 2024 08:50:28 +0100 Subject: [PATCH] rrd_rpncalc: Quiet gcc warning by copying one extra character. (#1243) 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 --- src/rrd_rpncalc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rrd_rpncalc.c b/src/rrd_rpncalc.c index 6eef36bb..bb923dce 100644 --- a/src/rrd_rpncalc.c +++ b/src/rrd_rpncalc.c @@ -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; } -- 2.47.2