:: commit 16401fb825433c5768d468b700427c20ff3d6432

Mintsuki <mintsuki@protonmail.com> — 2026-04-17 00:18

parents: 8a1cf6310f

lib/elf: Validate rela_size is a multiple of rela_ent

diff --git a/common/lib/elf.c b/common/lib/elf.c
index 50c851ad..e2fd4239 100644
--- a/common/lib/elf.c
+++ b/common/lib/elf.c
@@ -448,6 +448,9 @@ end_of_pt_segment:
         if (rela_ent < sizeof(struct elf64_rela)) {
             panic(true, "elf: rela_ent < sizeof(struct elf64_rela)");
         }
+        if (rela_size % rela_ent != 0) {
+            panic(true, "elf: rela_size not a multiple of rela_ent");
+        }
         relocs_i += rela_size / rela_ent;
     }
     if (dt_pltrelsz != 0) {
tab: 248 wrap: offon