Skip to content

Commit

Permalink
staging: sep: using strlcpy instead of strncpy
Browse files Browse the repository at this point in the history
  set '\0' at tail for NUL terminated string, or TP_printk may cause issue.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Chen Gang authored and Greg Kroah-Hartman committed Mar 11, 2013
1 parent acb84e9 commit 6d8a94e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/staging/sep/sep_trace_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
*/
#include <linux/tracepoint.h>

/*
* Since use str*cpy in header file, better to include string.h, directly.
*/
#include <linux/string.h>

/*
* The TRACE_EVENT macro is broken up into 5 parts.
*
Expand Down Expand Up @@ -97,7 +102,7 @@ TRACE_EVENT(sep_func_start,
),

TP_fast_assign(
strncpy(__entry->name, name, 20);
strlcpy(__entry->name, name, 20);
__entry->branch = branch;
),

Expand All @@ -116,7 +121,7 @@ TRACE_EVENT(sep_func_end,
),

TP_fast_assign(
strncpy(__entry->name, name, 20);
strlcpy(__entry->name, name, 20);
__entry->branch = branch;
),

Expand All @@ -135,7 +140,7 @@ TRACE_EVENT(sep_misc_event,
),

TP_fast_assign(
strncpy(__entry->name, name, 20);
strlcpy(__entry->name, name, 20);
__entry->branch = branch;
),

Expand Down

0 comments on commit 6d8a94e

Please sign in to comment.