Skip to content

Commit

Permalink
bpftool: Replace strncpy with strscpy
Browse files Browse the repository at this point in the history
strncpy() is deprecated for NUL-terminated destination buffers. Use
strscpy() instead and remove the manual NUL-termination.

Compile-tested only.

Link: KSPP/linux#90

Signed-off-by: Michael Estner <michaelestner@web.de>
  • Loading branch information
MEstner authored and Kernel Patches Daemon committed Feb 28, 2025
1 parent e68fc46 commit 55484e7
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions tools/bpf/bpftool/xlated_dumper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 55484e7

Please sign in to comment.