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
1 changed files with 4 additions and 0 deletions

View File

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