[PATCH linux-next] tools x86 machine: use strscpy() is more robust and safer

From: cgel . zte
Date: Wed Sep 21 2022 - 05:36:12 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/arch/x86/util/machine.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/arch/x86/util/machine.c b/tools/perf/arch/x86/util/machine.c
index 31679c35d493..1ff0be147205 100644
--- a/tools/perf/arch/x86/util/machine.c
+++ b/tools/perf/arch/x86/util/machine.c
@@ -40,7 +40,7 @@ static int add_extra_kernel_map(struct extra_kernel_map_info *mi, u64 start,
mi->maps[mi->cnt].start = start;
mi->maps[mi->cnt].end = end;
mi->maps[mi->cnt].pgoff = pgoff;
- strlcpy(mi->maps[mi->cnt].name, name, KMAP_NAME_LEN);
+ strscpy(mi->maps[mi->cnt].name, name, KMAP_NAME_LEN);

mi->cnt += 1;

--
2.25.1