lkml.org 
[lkml]   [2022]   [Sep]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH linux-next] perf machine: use strscpy() is more robust and safer
Date
From: ye xingchen <ye.xingchen@zte.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@zte.com.cn>
Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
---
tools/perf/util/machine.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 2a16cae28407..5d0f817cef63 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1198,7 +1198,7 @@ int machine__create_extra_kernel_map(struct machine *machine,

kmap = map__kmap(map);

- strlcpy(kmap->name, xm->name, KMAP_NAME_LEN);
+ strscpy(kmap->name, xm->name, KMAP_NAME_LEN);

maps__insert(machine__kernel_maps(machine), map);

@@ -1287,7 +1287,7 @@ int machine__map_x86_64_entry_trampolines(struct machine *machine,
.pgoff = pgoff,
};

- strlcpy(xm.name, ENTRY_TRAMPOLINE_NAME, KMAP_NAME_LEN);
+ strscpy(xm.name, ENTRY_TRAMPOLINE_NAME, KMAP_NAME_LEN);

if (machine__create_extra_kernel_map(machine, kernel, &xm) < 0)
return -1;
@@ -1892,7 +1892,7 @@ int machine__process_mmap2_event(struct machine *machine,
.pgoff = event->mmap2.pgoff,
};

- strlcpy(xm.name, event->mmap2.filename, KMAP_NAME_LEN);
+ strscpy(xm.name, event->mmap2.filename, KMAP_NAME_LEN);
ret = machine__process_kernel_mmap_event(machine, &xm, bid);
if (ret < 0)
goto out_problem;
@@ -1949,7 +1949,7 @@ int machine__process_mmap_event(struct machine *machine, union perf_event *event
.pgoff = event->mmap.pgoff,
};

- strlcpy(xm.name, event->mmap.filename, KMAP_NAME_LEN);
+ strscpy(xm.name, event->mmap.filename, KMAP_NAME_LEN);
ret = machine__process_kernel_mmap_event(machine, &xm, NULL);
if (ret < 0)
goto out_problem;
--
2.25.1
\
 
 \ /
  Last update: 2022-09-21 11:39    [W:0.067 / U:0.968 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site