mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-23 02:51:47 +00:00
tools: bpftool: prevent infinite loop in get_fdinfo()
[ Upstream commit53909030aa
] 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:71bb428fe2
("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
136c523734
commit
b42ab52844
1 changed files with 1 additions and 1 deletions
|
@ -304,7 +304,7 @@ char *get_fdinfo(int fd, const char *key)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
while ((n = getline(&line, &line_n, fdi))) {
|
||||
while ((n = getline(&line, &line_n, fdi)) > 0) {
|
||||
char *value;
|
||||
int len;
|
||||
|
||||
|
|
Loading…
Reference in a new issue