diff options
author | Chen Gang <gang.chen@asianux.com> | 2013-04-07 23:48:27 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2013-04-08 07:26:55 -0400 |
commit | c97847d2f0eb77c806e650e04d9bbcf79fa05730 (patch) | |
tree | b55f1ce399ed36116f5a39f735afc4693c85a9d6 /kernel/events | |
parent | dd9c086d9f507d02d5ba4d7c5eef4bb9518088b8 (diff) |
perf: Fix strncpy() use, always make sure it's NUL terminated
For NUL terminated string, always make sure that there's '\0' at the end.
In our case we need a return value, so still use strncpy() and
fix up the tail explicitly.
(strlcpy() returns the size, not the pointer)
Signed-off-by: Chen Gang <gang.chen@asianux.com>
Cc: a.p.zijlstra@chello.nl <a.p.zijlstra@chello.nl>
Cc: paulus@samba.org <paulus@samba.org>
Cc: acme@ghostprotocols.net <acme@ghostprotocols.net>
Link: http://lkml.kernel.org/r/51623E0B.7070101@asianux.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/events')
-rw-r--r-- | kernel/events/core.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c index 59412d037eed..7f0d67ea3f48 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -4737,7 +4737,8 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event) | |||
4737 | } else { | 4737 | } else { |
4738 | if (arch_vma_name(mmap_event->vma)) { | 4738 | if (arch_vma_name(mmap_event->vma)) { |
4739 | name = strncpy(tmp, arch_vma_name(mmap_event->vma), | 4739 | name = strncpy(tmp, arch_vma_name(mmap_event->vma), |
4740 | sizeof(tmp)); | 4740 | sizeof(tmp) - 1); |
4741 | tmp[sizeof(tmp) - 1] = '\0'; | ||
4741 | goto got_name; | 4742 | goto got_name; |
4742 | } | 4743 | } |
4743 | 4744 | ||