Skip to content

eBPF-based security platform

elf_target: take the build-id note by its whole name

Daniel Borkmann712a30660e8f
diff --git a/util/elf_target.c b/util/elf_target.c
index dbb01e50..9fb5379b 100644
--- a/util/elf_target.c
+++ b/util/elf_target.c
@@ -55,10 +55,10 @@ static int note_build_id(Elf_Data *data,
next = gelf_getnote(data, off, &nhdr, &name_off, &desc_off);
if (!next)
break;
- if (nhdr.n_type == NT_GNU_BUILD_ID && nhdr.n_namesz >= 3 &&
+ if (nhdr.n_type == NT_GNU_BUILD_ID && nhdr.n_namesz == 4 &&
name_off <= data->d_size && nhdr.n_namesz <= data->d_size - name_off &&
desc_off <= data->d_size && nhdr.n_descsz <= data->d_size - desc_off &&
- memcmp(p + name_off, "GNU", 3) == 0) {
+ memcmp(p + name_off, "GNU", 4) == 0) {
if (!nhdr.n_descsz ||
nhdr.n_descsz > SHIRUDO_UPATCH_BUILD_ID_MAX)
return -E2BIG;