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 0ad8f9b5ad
commit 36ce4f292d

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)");
}