summaryrefslogtreecommitdiff
path: root/mld/link.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--mld/link.c4
1 files changed, 4 insertions, 0 deletions
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;