diff options
| author | Subha sree Mohankumar <smohanku@redhat.com> | 2017-09-22 16:13:44 +0530 | 
|---|---|---|
| committer | Jeff Darcy <jeff@pl.atyp.us> | 2017-10-10 15:46:20 +0000 | 
| commit | dc3cd44add80fb56fae2492cb8ad264be04f46fc (patch) | |
| tree | f6dc93007f9c089538ff718a1ffbdfd3cc8ddd11 /xlators/debug/trace/src/trace.c | |
| parent | 3afbe4201d864d2e886509f5633468aa344fa444 (diff) | |
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 <smohanku@redhat.com>
Diffstat (limited to 'xlators/debug/trace/src/trace.c')
| -rw-r--r-- | xlators/debug/trace/src/trace.c | 6 | 
1 files 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;                  }          }  | 
