summaryrefslogtreecommitdiffstats
path: root/libelf/elf_data.c
diff options
context:
space:
mode:
Diffstat (limited to 'libelf/elf_data.c')
-rw-r--r--libelf/elf_data.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libelf/elf_data.c b/libelf/elf_data.c
index ce80e1c..3d8ef6c 100644
--- a/libelf/elf_data.c
+++ b/libelf/elf_data.c
@@ -32,7 +32,7 @@
#include "_libelf.h"
-ELFTC_VCSID("$Id: elf_data.c 3177 2015-03-30 18:19:41Z emaste $");
+ELFTC_VCSID("$Id: elf_data.c 3258 2015-11-20 18:59:43Z emaste $");
Elf_Data *
elf_getdata(Elf_Scn *s, Elf_Data *ed)
@@ -253,6 +253,12 @@ elf_rawdata(Elf_Scn *s, Elf_Data *ed)
return (NULL);
}
+ if (sh_type != SHT_NOBITS &&
+ sh_offset + sh_size > (uint64_t) e->e_rawsize) {
+ LIBELF_SET_ERROR(SECTION, 0);
+ return (NULL);
+ }
+
if ((d = _libelf_allocate_data(s)) == NULL)
return (NULL);
OpenPOWER on IntegriCloud