elf: elf64_load_section(): Return false early if sh_num == 0

This commit is contained in:
mintsuki 2023-08-17 14:31:49 -05:00
parent 27a32e416c
commit 573d0095bf

View File

@ -297,6 +297,10 @@ bool elf64_load_section(uint8_t *elf, void *buffer, const char *name, size_t lim
#error Unknown architecture
#endif
if (hdr->sh_num == 0) {
return false;
}
if (hdr->shdr_size < sizeof(struct elf64_shdr)) {
panic(true, "elf: shdr_size < sizeof(struct elf64_shdr)");
}