libbpf: Fix str_has_sfx()'s return value
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 19 Jul 2022 09:53:01 +0000 (12:53 +0300)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 21 Jul 2022 12:30:25 +0000 (14:30 +0200)
The return from strcmp() is inverted so it wrongly returns true instead
of false and vice versa.

Fixes: a1c9d61b19cb ("libbpf: Improve library identification for uprobe binary path resolution")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Cc: Alan Maguire <alan.maguire@oracle.com>
Link: https://lore.kernel.org/bpf/YtZ+/dAA195d99ak@kili
tools/lib/bpf/libbpf_internal.h

index f01dbab..4135ae0 100644 (file)
@@ -108,9 +108,9 @@ static inline bool str_has_sfx(const char *str, const char *sfx)
        size_t str_len = strlen(str);
        size_t sfx_len = strlen(sfx);
 
-       if (sfx_len <= str_len)
-               return strcmp(str + str_len - sfx_len, sfx);
-       return false;
+       if (sfx_len > str_len)
+               return false;
+       return strcmp(str + str_len - sfx_len, sfx) == 0;
 }
 
 /* Symbol versioning is different between static and shared library.