aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2019-02-11 16:15:59 +0000
committerNick Clifton <nickc@redhat.com>2019-02-11 16:15:59 +0000
commitc6f021093dbd26b4d8e761e9a19af817e9f2561f (patch)
tree9fb99884795b3bf34e9f72705b134ed75f281ceb
parentc6af0afb3616c2ce5ba2950d17532c6744617c2a (diff)
downloadfsf-binutils-gdb-c6f021093dbd26b4d8e761e9a19af817e9f2561f.zip
fsf-binutils-gdb-c6f021093dbd26b4d8e761e9a19af817e9f2561f.tar.gz
fsf-binutils-gdb-c6f021093dbd26b4d8e761e9a19af817e9f2561f.tar.bz2
Fix a NULL pointer dereference in nm, when parsing a corrupt file.
PR 24168 * nm.c (print_symbol): Check for NULL contents of the sym_ptr_ptr field.
-rw-r--r--binutils/ChangeLog6
-rw-r--r--binutils/nm.c3
2 files changed, 9 insertions, 0 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 0eba844..ad4f226 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,9 @@
+2019-02-11 Nick Clifton <nickc@redhat.com>
+
+ PR 24168
+ * nm.c (print_symbol): Check for NULL contents of the sym_ptr_ptr
+ field.
+
2018-03-19 H.J. Lu <hongjiu.lu@intel.com>
Backport from master branch
diff --git a/binutils/nm.c b/binutils/nm.c
index e46fffc..afaea56 100644
--- a/binutils/nm.c
+++ b/binutils/nm.c
@@ -976,6 +976,7 @@ print_symbol (bfd * abfd,
}
symname = bfd_asymbol_name (sym);
+
for (i = 0; i < seccount; i++)
{
long j;
@@ -985,7 +986,9 @@ print_symbol (bfd * abfd,
arelent *r;
r = relocs[i][j];
+
if (r->sym_ptr_ptr != NULL
+ && * r->sym_ptr_ptr != NULL
&& (*r->sym_ptr_ptr)->section == sym->section
&& (*r->sym_ptr_ptr)->value == sym->value
&& strcmp (symname,