[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250228181827.90436-1-michaelestner@web.de>
Date: Fri, 28 Feb 2025 19:18:27 +0100
From: Michael Estner <michaelestner@....de>
To: qmo@...nel.org,
ast@...nel.org,
daniel@...earbox.net
Cc: bpf@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-hardening@...r.kernel.org,
Michael Estner <michaelestner@....de>
Subject: [PATCH] bpftool: Replace strncpy with strscpy
strncpy() is deprecated for NUL-terminated destination buffers. Use
strscpy() instead and remove the manual NUL-termination.
Compile-tested only.
Link: https://github.com/KSPP/linux/issues/90
Signed-off-by: Michael Estner <michaelestner@....de>
---
tools/bpf/bpftool/xlated_dumper.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tools/bpf/bpftool/xlated_dumper.c b/tools/bpf/bpftool/xlated_dumper.c
index d0094345fb2b..60dbe48a91a3 100644
--- a/tools/bpf/bpftool/xlated_dumper.c
+++ b/tools/bpf/bpftool/xlated_dumper.c
@@ -135,8 +135,7 @@ print_insn_json(void *private_data, const char *fmt, ...)
va_start(args, fmt);
if (l > 0) {
- strncpy(chomped_fmt, fmt, l - 1);
- chomped_fmt[l - 1] = '\0';
+ strscpy(chomped_fmt, fmt);
}
jsonw_vprintf_enquote(json_wtr, chomped_fmt, args);
va_end(args);
--
2.25.1
Powered by blists - more mailing lists