From: Chen Gang <gang.chen@asianux.com>
To: "a.p.zijlstra@chello.nl" <a.p.zijlstra@chello.nl>,
"paulus@samba.org" <paulus@samba.org>,
"mingo@redhat.com" <mingo@redhat.com>,
"acme@ghostprotocols.net" <acme@ghostprotocols.net>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH] kernel: events: strncpy, always be sure of NUL terminated.
Date: Mon, 08 Apr 2013 11:48:27 +0800 [thread overview]
Message-ID: <51623E0B.7070101@asianux.com> (raw)
for NUL terminated string, always be sure of '\0' at the end.
in our case, need return value, so still use strncpy
(strlcpy return the size, not the pointer)
Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
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 4757941..bdc0e25 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -4752,7 +4752,8 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
} else {
if (arch_vma_name(mmap_event->vma)) {
name = strncpy(tmp, arch_vma_name(mmap_event->vma),
- sizeof(tmp));
+ sizeof(tmp) - 1);
+ tmp[sizeof(tmp) - 1] = '\0';
goto got_name;
}
--
1.7.7.6
next reply other threads:[~2013-04-08 3:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-08 3:48 Chen Gang [this message]
2013-04-08 15:29 ` [tip:perf/urgent] perf: Fix strncpy() use, always make sure it' s NUL terminated tip-bot for Chen Gang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51623E0B.7070101@asianux.com \
--to=gang.chen@asianux.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox