summaryrefslogtreecommitdiff
path: root/mld/link.c
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2024-09-22 16:44:54 -0400
committerFreya Murphy <freya@freyacat.org>2024-09-22 16:44:54 -0400
commitbf39d3283bbc83773459ae5d399ead2bf4452fb7 (patch)
tree9826d286dba8ec8f0b6fe23af5aafbc7f4e48ad2 /mld/link.c
parentmld done (diff)
downloadmips-bf39d3283bbc83773459ae5d399ead2bf4452fb7.tar.gz
mips-bf39d3283bbc83773459ae5d399ead2bf4452fb7.tar.bz2
mips-bf39d3283bbc83773459ae5d399ead2bf4452fb7.zip
fix mem errors
Diffstat (limited to 'mld/link.c')
-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;