summaryrefslogtreecommitdiff
path: root/ld/libdep_plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'ld/libdep_plugin.c')
-rw-r--r--ld/libdep_plugin.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ld/libdep_plugin.c b/ld/libdep_plugin.c
index 5569aa45e36..453df71c15b 100644
--- a/ld/libdep_plugin.c
+++ b/ld/libdep_plugin.c
@@ -99,6 +99,7 @@ get_libdeps (int fd)
arhdr ah;
int len;
unsigned long mlen;
+ size_t amt;
linerec *lr;
enum ld_plugin_status rc = LDPS_NO_SYMS;
@@ -114,7 +115,10 @@ get_libdeps (int fd)
lseek (fd, mlen, SEEK_CUR);
continue;
}
- lr = malloc (sizeof (linerec) + mlen);
+ amt = mlen + sizeof (linerec);
+ if (amt <= mlen)
+ return LDPS_ERR;
+ lr = malloc (amt);
if (!lr)
return LDPS_ERR;
lr->next = NULL;