:: commit f784baf39797a0018dee43045916be9c4aa20030

mintsuki <mintsuki@protonmail.com> — 2023-08-17 19:31

parents: 57c6490a32

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

diff --git a/common/lib/elf.c b/common/lib/elf.c
index fb914b24..78585673 100644
--- a/common/lib/elf.c
+++ b/common/lib/elf.c
@@ -285,6 +285,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)");
     }
tab: 248 wrap: offon