aboutsummaryrefslogtreecommitdiffstats
path: root/tools/bpf/bpftool/json_writer.c
diff options
context:
space:
mode:
authorLuis Gerhorst <[email protected]>2023-02-27 15:08:54 +0000
committerAndrii Nakryiko <[email protected]>2023-02-27 19:28:16 +0000
commitc679bbd611c08b0559ffae079330bc4e5574696a (patch)
tree01d17eb881ca7b0bd1c433250d1270155775db39 /tools/bpf/bpftool/json_writer.c
parentselftests/bpf: Use __NR_prlimit64 instead of __NR_getrlimit in user_ringbuf test (diff)
downloadkernel-c679bbd611c08b0559ffae079330bc4e5574696a.tar.gz
kernel-c679bbd611c08b0559ffae079330bc4e5574696a.zip
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: b66e907cfee2 ("tools: bpftool: copy JSON writer from iproute2 repository") Signed-off-by: Luis Gerhorst <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Reviewed-by: Quentin Monnet <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/bpf/bpftool/json_writer.c')
-rw-r--r--tools/bpf/bpftool/json_writer.c3
1 files changed, 0 insertions, 3 deletions
diff --git a/tools/bpf/bpftool/json_writer.c b/tools/bpf/bpftool/json_writer.c
index 7fea83bedf48..bca5dd0a59e3 100644
--- a/tools/bpf/bpftool/json_writer.c
+++ b/tools/bpf/bpftool/json_writer.c
@@ -80,9 +80,6 @@ static void jsonw_puts(json_writer_t *self, const char *str)
case '"':
fputs("\\\"", self->out);
break;
- case '\'':
- fputs("\\\'", self->out);
- break;
default:
putc(*str, self->out);
}