From bf39d3283bbc83773459ae5d399ead2bf4452fb7 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Sun, 22 Sep 2024 16:44:54 -0400 Subject: fix mem errors --- mld/link.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'mld/link.c') diff --git a/mld/link.c b/mld/link.c index de703c2..5696973 100644 --- a/mld/link.c +++ b/mld/link.c @@ -399,6 +399,10 @@ static int relocate_instruction_rela(struct linker *linker, /// get the segment that the symbol is in struct segment_table_entry *ent; const char *segname = seg->obj->shstrtab->data + B32(shdr->sh_name); + if (B32(shdr->sh_name) >= seg->obj->shstrtab->len) { + ERROR("relocation segment name out of bounds"); + return M_ERROR; + } if (segtab_get(&linker->segments, &ent, segname)) { ERROR("could not locate segment for relocation"); return M_ERROR; -- cgit v1.2.3-freya