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: 004b45c0 ("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>
Showing
Please register or sign in to comment