linux/tools/bpf/bpftool
Luis Gerhorst c679bbd611 tools: bpftool: Remove invalid \' json escape
RFC8259 ("The JavaScript Object Notation (JSON) Data Interchange
Format") only specifies \", \\, \/, \b, \f, \n, \r, and \r as valid
two-character escape sequences. This does not include \', which is not
required in JSON because it exclusively uses double quotes as string
separators.

Solidus (/) may be escaped, but does not have to. Only reverse
solidus (\), double quotes ("), and the control characters have to be
escaped. Therefore, with this fix, bpftool correctly supports all valid
two-character escape sequences (but still does not support characters
that require multi-character escape sequences).

Witout this fix, attempting to load a JSON file generated by bpftool
using Python 3.10.6's default json.load() may fail with the error
"Invalid \escape" if the file contains the invalid escaped single
quote (\').

Fixes: b66e907cfe ("tools: bpftool: copy JSON writer from iproute2 repository")
Signed-off-by: Luis Gerhorst <gerhorst@cs.fau.de>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Quentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/bpf/20230227150853.16863-1-gerhorst@cs.fau.de
2023-02-27 11:28:16 -08:00
..
bash-completion bpftool: remove support of --legacy option for bpftool 2022-11-20 16:17:46 -08:00
Documentation bpftool: remove support of --legacy option for bpftool 2022-11-20 16:17:46 -08:00
skeleton bpftool: Add bpf_cookie to link output 2022-03-15 15:07:27 -07:00
.gitignore bpftool: Fix SPDX tag for Makefiles and .gitignore 2021-11-10 09:00:52 -08:00
btf_dumper.c bpftool: Use bpf_{btf,link,map,prog}_get_info_by_fd() 2023-02-16 15:32:45 -08:00
btf.c bpftool: Use bpf_{btf,link,map,prog}_get_info_by_fd() 2023-02-16 15:32:45 -08:00
cfg.c tools, bpftool: Poison and replace kernel integer typedefs 2020-05-11 21:20:46 +02:00
cfg.h tools: bpftool: replace Netronome boilerplate with SPDX license headers 2018-12-13 12:08:44 +01:00
cgroup.c bpftool: Use bpf_{btf,link,map,prog}_get_info_by_fd() 2023-02-16 15:32:45 -08:00
common.c bpftool: Use bpf_{btf,link,map,prog}_get_info_by_fd() 2023-02-16 15:32:45 -08:00
feature.c bpftool: fix output for skipping kernel config check 2023-01-10 17:42:31 -08:00
gen.c bpftool: clean-up usage of libbpf_get_error() 2022-11-20 16:17:46 -08:00
iter.c bpftool: clean-up usage of libbpf_get_error() 2022-11-20 16:17:46 -08:00
jit_disasm.c bpftool: Fix spelling mistake "disasembler" -> "disassembler" 2022-10-26 18:20:22 -07:00
json_writer.c tools: bpftool: Remove invalid \' json escape 2023-02-27 11:28:16 -08:00
json_writer.h bpftool: Support dumping metadata 2020-09-15 18:28:27 -07:00
link.c bpftool: Use bpf_{btf,link,map,prog}_get_info_by_fd() 2023-02-16 15:32:45 -08:00
main.c bpftool: clean-up usage of libbpf_get_error() 2022-11-20 16:17:46 -08:00
main.h bpftool: Use bpf_{btf,link,map,prog}_get_info_by_fd() 2023-02-16 15:32:45 -08:00
Makefile bpftool: Always disable stack protection for BPF objects 2023-01-13 16:44:21 +01:00
map_perf_ring.c bpftool: Fix error message of strerror 2022-09-30 15:40:46 -07:00
map.c bpftool: Use bpf_{btf,link,map,prog}_get_info_by_fd() 2023-02-16 15:32:45 -08:00
net.c bpftool: Define _GNU_SOURCE only once 2022-10-25 10:11:56 -07:00
netlink_dumper.c bpftool: Use consistent include paths for libbpf 2020-01-20 16:37:45 -08:00
netlink_dumper.h tools: bpftool: dual license all files 2018-12-13 12:08:44 +01:00
perf.c bpftool: Define _GNU_SOURCE only once 2022-10-25 10:11:56 -07:00
pids.c libbpf: Hashmap interface update to allow both long and void* keys/values 2022-11-09 20:45:14 -08:00
prog.c bpftool: Use bpf_{btf,link,map,prog}_get_info_by_fd() 2023-02-16 15:32:45 -08:00
struct_ops.c bpftool: Use bpf_{btf,link,map,prog}_get_info_by_fd() 2023-02-16 15:32:45 -08:00
tracelog.c bpftool, musl compat: Replace sys/fcntl.h by fcntl.h 2022-04-25 23:24:28 +02:00
xlated_dumper.c bpftool: Define _GNU_SOURCE only once 2022-10-25 10:11:56 -07:00
xlated_dumper.h tools: bpftool: replace Netronome boilerplate with SPDX license headers 2018-12-13 12:08:44 +01:00