提交 d8fae2f6 编写于 作者: Z Zhao Hongjiang 提交者: Steven Rostedt

tracing: Change trace event sample to use strlcpy instead of strncpy

Strings should be copied with strlcpy instead of strncpy when they will
later be printed via %s. This guarantees that they terminate with a
NUL '\0' character and do not run pass the end of the allocated string.

This is only for sample code, but it should stil represent a good
role model.

Link: http://lkml.kernel.org/p/51C2E204.1080501@huawei.comSigned-off-by: NZhao Hongjiang <zhaohongjiang@huawei.com>
Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
上级 9674b2fa
......@@ -87,7 +87,7 @@ TRACE_EVENT(foo_bar,
),
TP_fast_assign(
strncpy(__entry->foo, foo, 10);
strlcpy(__entry->foo, foo, 10);
__entry->bar = bar;
),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册