]> git.baikalelectronics.ru Git - kernel.git/commit
tools: bpftool: prevent infinite loop in get_fdinfo()
authorQuentin Monnet <quentin.monnet@netronome.com>
Thu, 8 Nov 2018 11:52:25 +0000 (11:52 +0000)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 9 Nov 2018 07:20:52 +0000 (08:20 +0100)
commitff403c64d2eda9c789c0b2b91553ffbffaafa9fd
tree8f36333c5fb18e5feb333c4de48be0e5b7c53bb2
parent58d152003f71d6d53ced1100cf0f7bbe3f3f809f
tools: bpftool: prevent infinite loop in get_fdinfo()

Function getline() returns -1 on failure to read a line, thus creating
an infinite loop in get_fdinfo() if the key is not found. Fix it by
calling the function only as long as we get a strictly positive return
value.

Found by copying the code for a key which is not always present...

Fixes: 9ffb478b4d49 ("tools: bpf: add bpftool")
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/bpf/bpftool/common.c