[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220921093149.230523-1-ye.xingchen@zte.com.cn>
Date: Wed, 21 Sep 2022 09:31:49 +0000
From: cgel.zte@...il.com
To: acme@...nel.org
Cc: mingo@...hat.com, mark.rutland@....com,
alexander.shishkin@...ux.intel.com, jolsa@...nel.org,
namhyung@...nel.org, linux-perf-users@...r.kernel.org,
linux-kernel@...r.kernel.org, ye xingchen <ye.xingchen@....com.cn>,
Zeal Robot <zealci@....com.cn>
Subject: [PATCH linux-next] perf buildid-cache: use strscpy() is more robust and safer
From: ye xingchen <ye.xingchen@....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@....com.cn>
Signed-off-by: ye xingchen <ye.xingchen@....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
Powered by blists - more mailing lists