aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2016-12-01 10:15:07 +0000
committerNick Clifton <nickc@redhat.com>2016-12-01 10:15:07 +0000
commit50455f1ab2935f7321215dfa681745c9b1cb5b19 (patch)
treea176d4e4826fe79be8c17e90c713b092b0e7ac01 /bfd
parent95a23284a3db0ec85bb0b11c70e6b5acf00563f6 (diff)
downloadgdb-50455f1ab2935f7321215dfa681745c9b1cb5b19.zip
gdb-50455f1ab2935f7321215dfa681745c9b1cb5b19.tar.gz
gdb-50455f1ab2935f7321215dfa681745c9b1cb5b19.tar.bz2
Fix seg-fault running addr2line on a corrupt binary.
PR binutils/20891 * aoutx.h (find_nearest_line): Handle the case where the main file name and the directory name are both empty.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/aoutx.h16
2 files changed, 18 insertions, 4 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index fc32759..8de43e0 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2016-12-01 Nick Clifton <nickc@redhat.com>
+
+ PR binutils/20891
+ * aoutx.h (find_nearest_line): Handle the case where the main file
+ name and the directory name are both 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 089fe57..614da21 100644
--- a/bfd/aoutx.h
+++ b/bfd/aoutx.h
@@ -2666,7 +2666,7 @@ NAME (aout, find_nearest_line) (bfd *abfd,
char *buf;
*filename_ptr = abfd->filename;
- *functionname_ptr = 0;
+ *functionname_ptr = NULL;
*line_ptr = 0;
if (disriminator_ptr)
*disriminator_ptr = 0;
@@ -2811,9 +2811,17 @@ NAME (aout, find_nearest_line) (bfd *abfd,
*filename_ptr = main_file_name;
else
{
- sprintf (buf, "%s%s", directory_name, main_file_name);
- *filename_ptr = buf;
- buf += filelen + 1;
+ if (buf == NULL)
+ /* PR binutils/20891: In a corrupt input file both
+ main_file_name and directory_name can be empty... */
+ * filename_ptr = NULL;
+ else
+ {
+ snprintf (buf, filelen + 1, "%s%s", directory_name,
+ main_file_name);
+ *filename_ptr = buf;
+ buf += filelen + 1;
+ }
}
}