Skip to content

Commit 14229b8

Browse files
Dan Carpenterborkmann
authored andcommitted
libbpf: Fix str_has_sfx()'s return value
The return from strcmp() is inverted so it wrongly returns true instead of false and vice versa. Fixes: a1c9d61 ("libbpf: Improve library identification for uprobe binary path resolution") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Martin KaFai Lau <[email protected]> Cc: Alan Maguire <[email protected]> Link: https://lore.kernel.org/bpf/YtZ+/dAA195d99ak@kili
1 parent c6018fc commit 14229b8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/lib/bpf/libbpf_internal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ static inline bool str_has_sfx(const char *str, const char *sfx)
108108
size_t str_len = strlen(str);
109109
size_t sfx_len = strlen(sfx);
110110

111-
if (sfx_len <= str_len)
112-
return strcmp(str + str_len - sfx_len, sfx);
113-
return false;
111+
if (sfx_len > str_len)
112+
return false;
113+
return strcmp(str + str_len - sfx_len, sfx) == 0;
114114
}
115115

116116
/* Symbol versioning is different between static and shared library.

0 commit comments

Comments
 (0)