:: commit 573d0095bf57988f25e558a232536b5ca89f5e61

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

parents: 27a32e416c

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

diff --git a/common/lib/elf.c b/common/lib/elf.c
index 1522c2b9..73c19979 100644
--- a/common/lib/elf.c
+++ b/common/lib/elf.c
@@ -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)");
     }
tab: 248 wrap: offon