]> git.baikalelectronics.ru Git - kernel.git/commit
tools: bpftool: fix crash on bad parameters with JSON
authorQuentin Monnet <quentin.monnet@netronome.com>
Wed, 29 Nov 2017 01:44:28 +0000 (17:44 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 30 Nov 2017 01:09:29 +0000 (02:09 +0100)
commit79232ba2f234069d6de618b215271b6f4f516812
treee9d2683c58114c5b9c78a058d881c117bf1fd75d
parent6db36a66b7ba7a40ef9bd323ea3666f5ab121592
tools: bpftool: fix crash on bad parameters with JSON

If bad or unrecognised parameters are specified after JSON output is
requested, `usage()` will try to output null JSON object before the
writer is created.

To prevent this, create the writer as soon as the `--json` option is
parsed.

Fixes: 9fe5eba4b079 ("tools: bpftool: provide JSON output for all possible commands")
Reported-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/bpf/bpftool/main.c