From: Andrii Nakryiko <andrii@kernel.org>
Date: Thu, 7 Apr 2022 16:04:45 -0700
Subject: libbpf: Use strlcpy() in path resolution fallback logic
Patch-mainline: v5.19-rc1
Git-commit: 3c0dfe6e4c43ea0cf252ff4cb7a332423866d488
References: jsc#PED-1377
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>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20220407230446.3980075-1-andrii@kernel.org
Acked-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
---
tools/lib/bpf/usdt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/tools/lib/bpf/usdt.c
+++ b/tools/lib/bpf/usdt.c
@@ -456,7 +456,7 @@ static int parse_lib_segs(int pid, const
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: