[PATCH linux-next] perf parse-events: use strscpy() is more robust and safer
From: cgel . zte
Date: Wed Sep 21 2022 - 05:33:58 EST
From: ye xingchen <ye.xingchen@xxxxxxxxxx>
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@xxxxxxxxxx>
Signed-off-by: ye xingchen <ye.xingchen@xxxxxxxxxx>
---
tools/perf/util/print-events.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/print-events.c b/tools/perf/util/print-events.c
index ba1ab5134685..36c242ea6314 100644
--- a/tools/perf/util/print-events.c
+++ b/tools/perf/util/print-events.c
@@ -430,7 +430,7 @@ static void print_tool_event(const struct event_symbol *syms, const char *event_
if (syms->alias && strlen(syms->alias))
snprintf(name, MAX_NAME_LEN, "%s OR %s", syms->symbol, syms->alias);
else
- strlcpy(name, syms->symbol, MAX_NAME_LEN);
+ strscpy(name, syms->symbol, MAX_NAME_LEN);
printf(" %-50s [%s]\n", name, "Tool event");
}
}
@@ -485,7 +485,7 @@ void print_symbol_events(const char *event_glob, unsigned int type,
if (!name_only && strlen(syms->alias))
snprintf(name, MAX_NAME_LEN, "%s OR %s", syms->symbol, syms->alias);
else
- strlcpy(name, syms->symbol, MAX_NAME_LEN);
+ strscpy(name, syms->symbol, MAX_NAME_LEN);
evt_list[evt_i] = strdup(name);
if (evt_list[evt_i] == NULL)
--
2.25.1