summaryrefslogtreecommitdiff
path: root/libelf
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2015-06-18 10:54:29 +0200
committerMark Wielaard <mjw@redhat.com>2015-06-19 12:27:22 +0200
commitaec69c7f2adcf9674f025c7f79cbeabbbd4e6b6a (patch)
tree9176f18ebc622a51e3576dc7f70b332057246711 /libelf
parent821e15c6ca716b17b3d3b678cfb17d12ef9bcf25 (diff)
downloadelfutils-aec69c7f2adcf9674f025c7f79cbeabbbd4e6b6a.tar.gz
libelf: Check symbol section header exists before use in nlist.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Diffstat (limited to 'libelf')
-rw-r--r--libelf/ChangeLog4
-rw-r--r--libelf/nlist.c8
2 files changed, 10 insertions, 2 deletions
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index 2d240074..2848f00c 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,7 @@
+2015-06-18 Mark Wielaard <mjw@redhat.com>
+
+ * nlist.c (nlist): Check symscn shdr exists before use.
+
2015-06-16 Mark Wielaard <mjw@redhat.com>
* elf_update.c (write_file): Always also use ftruncate before
diff --git a/libelf/nlist.c b/libelf/nlist.c
index 89fd0819..c7b32fdb 100644
--- a/libelf/nlist.c
+++ b/libelf/nlist.c
@@ -1,5 +1,5 @@
/* Extract symbol list from binary.
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005, 2007 Red Hat, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005, 2007, 2015 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 1998.
@@ -116,7 +116,11 @@ nlist (const char *filename, struct nlist *nl)
/* Re-get the section header in case we found only the dynamic symbol
table. */
if (scn == NULL)
- shdr = INTUSE(gelf_getshdr) (symscn, &shdr_mem);
+ {
+ shdr = INTUSE(gelf_getshdr) (symscn, &shdr_mem);
+ if (unlikely (shdr == NULL))
+ goto fail_close;
+ }
/* SHDR->SH_LINK now contains the index of the string section. */
/* Get the data for the symbol section. */