* [COMMITTED] readelf: Check def == NULL before use in handle_versym.
@ 2014-11-14 11:27 Mark Wielaard
0 siblings, 0 replies; only message in thread
From: Mark Wielaard @ 2014-11-14 11:27 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 1263 bytes --]
Don't use def if NULL. Move check earlier.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
src/ChangeLog | 4 ++++
src/readelf.c | 5 ++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index 6d3e951..be1d55f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2014-11-14 Mark Wielaard <mjw@redhat.com>
+
+ * readelf.c (handle_versym): Check def == NULL before use.
+
2014-11-08 Mark Wielaard <mjw@redhat.com>
* readelf.c (handle_versym): Initialize vername and filename array
diff --git a/src/readelf.c b/src/readelf.c
index 01c644f..243e16e 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -2744,11 +2744,14 @@ handle_versym (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr)
/* Get the data at the next offset. */
GElf_Verdef defmem;
GElf_Verdef *def = gelf_getverdef (defdata, offset, &defmem);
+ if (unlikely (def == NULL))
+ break;
+
GElf_Verdaux auxmem;
GElf_Verdaux *aux = gelf_getverdaux (defdata,
offset + def->vd_aux,
&auxmem);
- if (unlikely (def == NULL || aux == NULL))
+ if (unlikely (aux == NULL))
break;
vername[def->vd_ndx & 0x7fff]
--
1.8.3.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-11-14 11:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-14 11:27 [COMMITTED] readelf: Check def == NULL before use in handle_versym Mark Wielaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).