BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next 1/2] libbpf: use strlcpy() in path resolution fallback logic
@ 2022-04-07 23:04 Andrii Nakryiko
  2022-04-07 23:04 ` [PATCH bpf-next 2/2] libbpf: allow WEAK and GLOBAL bindings during BTF fixup Andrii Nakryiko
  2022-04-08 16:20 ` [PATCH bpf-next 1/2] libbpf: use strlcpy() in path resolution fallback logic patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Andrii Nakryiko @ 2022-04-07 23:04 UTC (permalink / raw)
  To: bpf, ast, daniel; +Cc: andrii, kernel-team

Coverity static analyzer complains that strcpy() can cause buffer
overflow. Use libbpf_strlcpy() instead to be 100% sure this doesn't
happen.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
 tools/lib/bpf/usdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/usdt.c b/tools/lib/bpf/usdt.c
index b699e720136a..5d7ba171ad39 100644
--- a/tools/lib/bpf/usdt.c
+++ b/tools/lib/bpf/usdt.c
@@ -456,7 +456,7 @@ static int parse_lib_segs(int pid, const char *lib_path, struct elf_seg **segs,
 	if (!realpath(lib_path, path)) {
 		pr_warn("usdt: failed to get absolute path of '%s' (err %d), using path as is...\n",
 			lib_path, -errno);
-		strcpy(path, lib_path);
+		libbpf_strlcpy(path, lib_path, sizeof(path));
 	}
 
 proceed:
-- 
2.30.2


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

end of thread, other threads:[~2022-04-08 16:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-07 23:04 [PATCH bpf-next 1/2] libbpf: use strlcpy() in path resolution fallback logic Andrii Nakryiko
2022-04-07 23:04 ` [PATCH bpf-next 2/2] libbpf: allow WEAK and GLOBAL bindings during BTF fixup Andrii Nakryiko
2022-04-08 16:20 ` [PATCH bpf-next 1/2] libbpf: use strlcpy() in path resolution fallback logic patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox