From dc3cd44add80fb56fae2492cb8ad264be04f46fc Mon Sep 17 00:00:00 2001 From: Subha sree Mohankumar Date: Fri, 22 Sep 2017 16:13:44 +0530 Subject: xlator/debug :coverity Issue BUFFER_SIZE Issue :Calling strncpy with a source string whose length (2 chars) is greater than or equal to the size argument (2) will fail to null-terminate "trace_fop_names[i].name". Solution : The size argument is obtained from sizeof(trace_fop_names[i].name). Change-Id: I99fad2693054f3af84d78da34c61258233d3049a BUG: 789278 Signed-off-by: Subha sree Mohankumar --- xlators/debug/trace/src/trace.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xlators/debug/trace/src/trace.c b/xlators/debug/trace/src/trace.c index 451ef9a0fe7..d9f88bff78e 100644 --- a/xlators/debug/trace/src/trace.c +++ b/xlators/debug/trace/src/trace.c @@ -3185,11 +3185,13 @@ init (xlator_t *this) if (gf_fop_list[i]) strncpy (trace_fop_names[i].name, gf_fop_list[i], - strlen (gf_fop_list[i])); + sizeof (trace_fop_names[i].name)); else strncpy (trace_fop_names[i].name, ":O", - strlen (":O")); + sizeof (trace_fop_names[i].name)); trace_fop_names[i].enabled = 1; + trace_fop_names[i].name[sizeof ( + trace_fop_names[i].name) - 1] = 0; } } -- cgit