summaryrefslogtreecommitdiff
path: root/tools/bpf/bpftool/btf.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/bpf/bpftool/btf.c')
-rw-r--r--tools/bpf/bpftool/btf.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c
index a7b8bf233cf5..e5bc97b71ceb 100644
--- a/tools/bpf/bpftool/btf.c
+++ b/tools/bpf/bpftool/btf.c
@@ -428,15 +428,15 @@ exit_close:
static bool is_btf_raw(const char *file)
{
__u16 magic = 0;
- int fd;
+ int fd, nb_read;
fd = open(file, O_RDONLY);
if (fd < 0)
return false;
- read(fd, &magic, sizeof(magic));
+ nb_read = read(fd, &magic, sizeof(magic));
close(fd);
- return magic == BTF_MAGIC;
+ return nb_read == sizeof(magic) && magic == BTF_MAGIC;
}
static int do_dump(int argc, char **argv)