[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220921093244.230579-1-ye.xingchen@zte.com.cn>
Date: Wed, 21 Sep 2022 09:32:44 +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, irogers@...gle.com, adrian.hunter@...el.com,
james.clark@....com, ye.xingchen@....com.cn, shaolexi@...wei.com,
mpetlan@...hat.com, linux-perf-users@...r.kernel.org,
linux-kernel@...r.kernel.org, Zeal Robot <zealci@....com.cn>
Subject: [PATCH linux-next] perf symbol: 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/util/symbol.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index a3a165ae933a..689007a23335 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1886,7 +1886,7 @@ int dso__load(struct dso *dso, struct map *map)
name);
if (new_name) {
is_reg = is_regular_file(new_name);
- strlcpy(name, new_name, PATH_MAX);
+ strscpy(name, new_name, PATH_MAX);
free(new_name);
}
}
@@ -2138,7 +2138,7 @@ static int find_matching_kcore(struct map *map, char *dir, size_t dir_sz)
scnprintf(kallsyms_filename, sizeof(kallsyms_filename),
"%s/%s/kallsyms", dir, nd->s);
if (!validate_kcore_addresses(kallsyms_filename, map)) {
- strlcpy(dir, kallsyms_filename, dir_sz);
+ strscpy(dir, kallsyms_filename, dir_sz);
ret = 0;
break;
}
--
2.25.1
Powered by blists - more mailing lists