[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220922013328.232998-1-ye.xingchen@zte.com.cn>
Date: Thu, 22 Sep 2022 01:33:28 +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,
leo.yan@...aro.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 synthetic-events: 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/synthetic-events.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c
index 0ff57ca24577..9f82b66f6271 100644
--- a/tools/perf/util/synthetic-events.c
+++ b/tools/perf/util/synthetic-events.c
@@ -1947,7 +1947,7 @@ int perf_event__synthesize_event_update_unit(struct perf_tool *tool, struct evse
if (ev == NULL)
return -ENOMEM;
- strlcpy(ev->unit, evsel->unit, size + 1);
+ strscpy(ev->unit, evsel->unit, size + 1);
err = process(tool, (union perf_event *)ev, NULL, NULL);
free(ev);
return err;
@@ -1981,7 +1981,7 @@ int perf_event__synthesize_event_update_name(struct perf_tool *tool, struct evse
if (ev == NULL)
return -ENOMEM;
- strlcpy(ev->name, evsel->name, len + 1);
+ strscpy(ev->name, evsel->name, len + 1);
err = process(tool, (union perf_event *)ev, NULL, NULL);
free(ev);
return err;
--
2.25.1
Powered by blists - more mailing lists