From: cgel.zte@gmail.com
To: acme@kernel.org
Cc: mingo@redhat.com, mark.rutland@arm.com,
alexander.shishkin@linux.intel.com, jolsa@kernel.org,
namhyung@kernel.org, adrian.hunter@intel.com, irogers@google.com,
james.clark@arm.com, alexandre.truong@arm.com,
blakejones@google.com, linux-perf-users@vger.kernel.org,
linux-kernel@vger.kernel.org,
ye xingchen <ye.xingchen@zte.com.cn>,
Zeal Robot <zealci@zte.com.cn>
Subject: [PATCH linux-next] perf machine: use strscpy() is more robust and safer
Date: Wed, 21 Sep 2022 09:38:48 +0000 [thread overview]
Message-ID: <20220921093848.230966-1-ye.xingchen@zte.com.cn> (raw)
From: ye xingchen <ye.xingchen@zte.com.cn>
The implementation of strscpy() is more robust and safer.
That's now the recommended way to copy NUL terminated strings.
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
---
tools/perf/util/machine.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 2a16cae28407..5d0f817cef63 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1198,7 +1198,7 @@ int machine__create_extra_kernel_map(struct machine *machine,
kmap = map__kmap(map);
- strlcpy(kmap->name, xm->name, KMAP_NAME_LEN);
+ strscpy(kmap->name, xm->name, KMAP_NAME_LEN);
maps__insert(machine__kernel_maps(machine), map);
@@ -1287,7 +1287,7 @@ int machine__map_x86_64_entry_trampolines(struct machine *machine,
.pgoff = pgoff,
};
- strlcpy(xm.name, ENTRY_TRAMPOLINE_NAME, KMAP_NAME_LEN);
+ strscpy(xm.name, ENTRY_TRAMPOLINE_NAME, KMAP_NAME_LEN);
if (machine__create_extra_kernel_map(machine, kernel, &xm) < 0)
return -1;
@@ -1892,7 +1892,7 @@ int machine__process_mmap2_event(struct machine *machine,
.pgoff = event->mmap2.pgoff,
};
- strlcpy(xm.name, event->mmap2.filename, KMAP_NAME_LEN);
+ strscpy(xm.name, event->mmap2.filename, KMAP_NAME_LEN);
ret = machine__process_kernel_mmap_event(machine, &xm, bid);
if (ret < 0)
goto out_problem;
@@ -1949,7 +1949,7 @@ int machine__process_mmap_event(struct machine *machine, union perf_event *event
.pgoff = event->mmap.pgoff,
};
- strlcpy(xm.name, event->mmap.filename, KMAP_NAME_LEN);
+ strscpy(xm.name, event->mmap.filename, KMAP_NAME_LEN);
ret = machine__process_kernel_mmap_event(machine, &xm, NULL);
if (ret < 0)
goto out_problem;
--
2.25.1
reply other threads:[~2022-09-21 9:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220921093848.230966-1-ye.xingchen@zte.com.cn \
--to=cgel.zte@gmail.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=alexandre.truong@arm.com \
--cc=blakejones@google.com \
--cc=irogers@google.com \
--cc=james.clark@arm.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=ye.xingchen@zte.com.cn \
--cc=zealci@zte.com.cn \
/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;
as well as URLs for NNTP newsgroup(s).