This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb/users/hjl/linux/master] Another fix for an objdump crash when parsing a corrupt binary.
- From: H.J.Lu <hjl at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 11 Jan 2015 16:20:26 -0000
- Subject: [binutils-gdb/users/hjl/linux/master] Another fix for an objdump crash when parsing a corrupt binary.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e7287c7f647870093b8ab5ffea0732ffdb8c4d66
commit e7287c7f647870093b8ab5ffea0732ffdb8c4d66
Author: Nick Clifton <nickc@redhat.com>
Date: Tue Jan 6 22:02:55 2015 +0000
Another fix for an objdump crash when parsing a corrupt binary.
PR binutils/17512
* mach-o.c (bfd_mach_o_read_symtab_strtab): Zero terminate the
string table.
Diff:
---
bfd/ChangeLog | 3 +++
bfd/mach-o.c | 4 +++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 383cf29..10ffe34 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,6 +1,9 @@
2015-01-06 Nick Clifton <nickc@redhat.com>
PR binutils/17512
+ * mach-o.c (bfd_mach_o_read_symtab_strtab): Zero terminate the
+ string table.
+
* reloc.c (bfd_get_reloc_size): Handle a reloc size of -1.
(bfd_perform_relocation): Include the size of the reloc in the
test for an out of range relocation.
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index 5dd6250..44b12b5 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -3675,7 +3675,7 @@ bfd_mach_o_read_symtab_strtab (bfd *abfd)
}
else
{
- sym->strtab = bfd_alloc (abfd, sym->strsize);
+ sym->strtab = bfd_alloc (abfd, sym->strsize + 1);
if (sym->strtab == NULL)
return FALSE;
@@ -3688,6 +3688,8 @@ bfd_mach_o_read_symtab_strtab (bfd *abfd)
bfd_set_error (bfd_error_file_truncated);
return FALSE;
}
+ /* Zero terminate the string table. */
+ sym->strtab[sym->strsize] = 0;
}
return TRUE;