From: tip-bot for Chen Gang <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, paulus@samba.org, hpa@zytor.com,
mingo@kernel.org, a.p.zijlstra@chello.nl,
acme@ghostprotocols.net, gang.chen@asianux.com,
tglx@linutronix.de
Subject: [tip:perf/urgent] perf: Fix strncpy() use, always make sure it' s NUL terminated
Date: Mon, 8 Apr 2013 08:29:24 -0700 [thread overview]
Message-ID: <tip-c97847d2f0eb77c806e650e04d9bbcf79fa05730@git.kernel.org> (raw)
In-Reply-To: <51623E0B.7070101@asianux.com>
Commit-ID: c97847d2f0eb77c806e650e04d9bbcf79fa05730
Gitweb: http://git.kernel.org/tip/c97847d2f0eb77c806e650e04d9bbcf79fa05730
Author: Chen Gang <gang.chen@asianux.com>
AuthorDate: Mon, 8 Apr 2013 11:48:27 +0800
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 8 Apr 2013 13:26:55 +0200
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>
---
kernel/events/core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 59412d0..7f0d67e 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)
} 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;
}
prev parent reply other threads:[~2013-04-08 16:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-08 3:48 [PATCH] kernel: events: strncpy, always be sure of NUL terminated Chen Gang
2013-04-08 15:29 ` tip-bot for Chen Gang [this message]
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=tip-c97847d2f0eb77c806e650e04d9bbcf79fa05730@git.kernel.org \
--to=tipbot@zytor.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=gang.chen@asianux.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paulus@samba.org \
--cc=tglx@linutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.