This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] Fix a seg-fault disassembling a corrupt binary.
- From: Nick Clifton <nickc at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 1 Dec 2016 10:50:11 -0000
- Subject: [binutils-gdb] Fix a seg-fault disassembling a corrupt binary.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e82ab856bb4689330c29fb9f1c57a8555b26380e
commit e82ab856bb4689330c29fb9f1c57a8555b26380e
Author: Nick Clifton <nickc@redhat.com>
Date: Thu Dec 1 10:49:39 2016 +0000
Fix a seg-fault disassembling a corrupt binary.
PR binutils/20892
* aoutx.h (find_nearest_line): Handle the case where the function
name is empty.
Diff:
---
bfd/ChangeLog | 4 ++++
bfd/aoutx.h | 6 ++++++
2 files changed, 10 insertions(+)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 8de43e0..f03aaeb 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -4,6 +4,10 @@
* aoutx.h (find_nearest_line): Handle the case where the main file
name and the directory name are both empty.
+ PR binutils/20892
+ * aoutx.h (find_nearest_line): Handle the case where the function
+ name is empty.
+
2016-11-30 Alan Modra <amodra@gmail.com>
* elf.c (get_program_header_size): Revert accidental change.
diff --git a/bfd/aoutx.h b/bfd/aoutx.h
index 614da21..4308679 100644
--- a/bfd/aoutx.h
+++ b/bfd/aoutx.h
@@ -2830,6 +2830,12 @@ NAME (aout, find_nearest_line) (bfd *abfd,
const char *function = func->name;
char *colon;
+ if (buf == NULL)
+ {
+ /* PR binutils/20892: In a corrupt input file func can be empty. */
+ * functionname_ptr = NULL;
+ return TRUE;
+ }
/* The caller expects a symbol name. We actually have a
function name, without the leading underscore. Put the
underscore back in, so that the caller gets a symbol name. */