* [PATCH linux-next] perf buildid-cache: use strscpy() is more robust and safer
@ 2022-09-21 9:31 cgel.zte
0 siblings, 0 replies; only message in thread
From: cgel.zte @ 2022-09-21 9:31 UTC (permalink / raw)
To: acme
Cc: mingo, mark.rutland, alexander.shishkin, jolsa, namhyung,
linux-perf-users, linux-kernel, ye xingchen, Zeal Robot
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/builtin-buildid-cache.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c
index cd381693658b..0cc4c39558ad 100644
--- a/tools/perf/builtin-buildid-cache.c
+++ b/tools/perf/builtin-buildid-cache.c
@@ -36,7 +36,7 @@ static int build_id_cache__kcore_buildid(const char *proc_dir, char *sbuildid)
char root_dir[PATH_MAX];
char *p;
- strlcpy(root_dir, proc_dir, sizeof(root_dir));
+ strscpy(root_dir, proc_dir, sizeof(root_dir));
p = strrchr(root_dir, '/');
if (!p)
@@ -104,7 +104,7 @@ static int build_id_cache__kcore_existing(const char *from_dir, char *to_dir,
to_dir, dent->d_name);
if (!compare_proc_modules(from, to) &&
same_kallsyms_reloc(from_dir, to_subdir)) {
- strlcpy(to_dir, to_subdir, to_dir_sz);
+ strscpy(to_dir, to_subdir, to_dir_sz);
ret = 0;
break;
}
@@ -121,7 +121,7 @@ static int build_id_cache__add_kcore(const char *filename, bool force)
char from_dir[PATH_MAX], to_dir[PATH_MAX];
char *p;
- strlcpy(from_dir, filename, sizeof(from_dir));
+ strscpy(from_dir, filename, sizeof(from_dir));
p = strrchr(from_dir, '/');
if (!p || strcmp(p + 1, "kcore"))
--
2.25.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-09-21 9:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-21 9:31 [PATCH linux-next] perf buildid-cache: use strscpy() is more robust and safer cgel.zte
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).