aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2015-12-12 17:08:19 -0500
committerMike Frysinger <vapier@gentoo.org>2015-12-12 17:08:19 -0500
commit871ce9d5e16d289bc1547781fe209086ea771e32 (patch)
tree85837120a6e7afc0b5e371ee1b56d1423d432e54
parentdumpelf: constify pointers (diff)
downloadpax-utils-871ce9d5e16d289bc1547781fe209086ea771e32.tar.gz
pax-utils-871ce9d5e16d289bc1547781fe209086ea771e32.tar.bz2
pax-utils-871ce9d5e16d289bc1547781fe209086ea771e32.zip
dumpelf: handle invalid section names
-rw-r--r--dumpelf.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/dumpelf.c b/dumpelf.c
index 5617f33..8abad61 100644
--- a/dumpelf.c
+++ b/dumpelf.c
@@ -223,6 +223,13 @@ static void dump_phdr(elfobj *elf, const void *phdr_void, long phdr_cnt)
static void dump_shdr(elfobj *elf, const void *shdr_void, long shdr_cnt, const char *name)
{
unsigned long i;
+
+ /* Make sure the string is valid. */
+ if ((void *)name >= elf->data_end)
+ name = "<corrupt>";
+ else if (memchr(name, 0, elf->len - (name - elf->data)) == NULL)
+ name = "<corrupt>";
+
#define DUMP_SHDR(B) \
if (elf->elf_class == ELFCLASS ## B) { \
const Elf ## B ## _Shdr *shdr = SHDR ## B (shdr_void); \