From 7bf30b0e371ad1170cd0773fe5db335683428777 Mon Sep 17 00:00:00 2001 From: Kamal Mohanan Date: Fri, 22 Sep 2017 11:33:47 +0530 Subject: xlators/debug/trace: Coverity Fix BUFFER_SIZE in reconfigure Problem: strncpy was being called with a source string of length equal to the size argument at lines 3110 and 3114. Solution: Calculate the size argument from the size of the destination argument. Change-Id: I1fed6f8f47c5512b9489bfb3297e7a9911eacbc8 BUG: 789278 Signed-off-by: Kamal Mohanan --- xlators/debug/trace/src/trace.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xlators/debug/trace/src/trace.c b/xlators/debug/trace/src/trace.c index d9f88bff78e..3ad3769afd8 100644 --- a/xlators/debug/trace/src/trace.c +++ b/xlators/debug/trace/src/trace.c @@ -3109,11 +3109,13 @@ reconfigure (xlator_t *this, dict_t *options) 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")); + strncpy (trace_fop_names[i].name, ":0", + 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