All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH linux-next] perf annotate: use strscpy() is more robust and safer
@ 2022-09-22  1:24 cgel.zte
  2022-09-22 19:19 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 2+ messages in thread
From: cgel.zte @ 2022-09-22  1:24 UTC (permalink / raw)
  To: acme
  Cc: mingo, mark.rutland, alexander.shishkin, jolsa, namhyung, irogers,
	songliubraving, adrian.hunter, davemarchevsky, wcohen, andres,
	linux-perf-users, linux-kernel, ye xingchen, Zeal Robot

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/annotate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 5bc63c9e0324..e2b038b14ff6 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1702,7 +1702,7 @@ static int dso__disassemble_filename(struct dso *dso, char *filename, size_t fil
 			char *new_name = filename_with_chroot(dso->nsinfo->pid,
 							      filename);
 			if (new_name) {
-				strlcpy(filename, new_name, filename_size);
+				strscpy(filename, new_name, filename_size);
 				free(new_name);
 			}
 		}
@@ -2002,7 +2002,7 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
 		kce.len = sym->end - sym->start;
 		if (!kcore_extract__create(&kce)) {
 			delete_extract = true;
-			strlcpy(symfs_filename, kce.extract_filename,
+			strscpy(symfs_filename, kce.extract_filename,
 				sizeof(symfs_filename));
 		}
 	} else if (dso__needs_decompress(dso)) {
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-22 19:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-22  1:24 [PATCH linux-next] perf annotate: use strscpy() is more robust and safer cgel.zte
2022-09-22 19:19 ` Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.