OSDN Git Service

bpf: fix uninitialized variable in bpf tools
authorJohn Fastabend <john.fastabend@gmail.com>
Wed, 25 Apr 2018 22:08:53 +0000 (15:08 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 26 Apr 2018 20:23:02 +0000 (22:23 +0200)
commit815425567dea6c54494e85050631d6bdda907c5d
treeb4b8abbdd15ea200595ae81616e94af48bd3e4ae
parent25eb0ea7174c6e84f21fa59dccbddd0318b17b12
bpf: fix uninitialized variable in bpf tools

Here the variable cont is used as the saved_pointer for a call to
strtok_r(). It is safe to use the value uninitialized in this
context however and the later reference is only ever used if
the strtok_r is successful. But, 'gcc-5' at least doesn't have all
this knowledge so initialize cont to NULL. Additionally, do the
natural NULL check before accessing just for completness.

The warning is the following:

./bpf/tools/bpf/bpf_dbg.c: In function ‘cmd_load’:
./bpf/tools/bpf/bpf_dbg.c:1077:13: warning: ‘cont’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  } else if (matches(subcmd, "pcap") == 0) {

Fixes: fd981e3c321a "filter: bpf_dbg: add minimal bpf debugger"
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/bpf/bpf_dbg.c