aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2015-01-21 17:37:23 +0000
committerNick Clifton <nickc@redhat.com>2015-01-21 17:37:23 +0000
commit86eafac0aad7edbc1ccea6daf53480a36339250a (patch)
tree380943f3951e65b5a0c9968691828a424e0857c7 /binutils
parentffbc46469f5fa1368251acd65da418775ab1a2ce (diff)
downloadgdb-86eafac0aad7edbc1ccea6daf53480a36339250a.zip
gdb-86eafac0aad7edbc1ccea6daf53480a36339250a.tar.gz
gdb-86eafac0aad7edbc1ccea6daf53480a36339250a.tar.bz2
Fix memory access violations triggered by running strip on fuzzed binaries.
PR binutils/17512 * coffcode.h (coff_set_arch_mach_hook): Check return value from bfd_malloc. (coff_slurp_line_table): Return FALSE if the line number information was corrupt. (coff_slurp_symbol_table): Return FALSE if the symbol information was corrupt. * mach-o.c (bfd_mach_o_bfd_copy_private_header_data): Always initialise the fields of the dyld_info structure. (bfd_mach_o_build_exec_seg_command): Replace assertion with an error message and a return value. (bfd_mach_o_layout_commands): Change the function to boolean. Return FALSE if the function fails. (bfd_mach_o_build_commands): Fail if bfd_mach_o_layout_commands fails. (bfd_mach_o_read_command): Fail if an unrecognised command is encountered. * peXXigen.c (_bfd_XXi_swap_aouthdr_in): Set bfd_error if the read fails. (slurp_symtab): Check the return from bfd_malloc. (_bfd_XX_bfd_copy_private_bfd_data_common): Fail if the copy encountered an error. (_bfd_XXi_final_link_postscript): Fail if a section could not be copied. * peicode.h (pe_bfd_object_p): Fail if the header could not be swapped in. * tekhex.c (first_phase): Fail if the section is too big. * versados.c (struct esdid): Add content_size field. (process_otr): Use and check the new field. (versados_get_section_contents): Check that the section exists and that the requested data is available. PR binutils/17512 * addr2line.c (main): Call bfd_set_error_program_name. * ar.c (main): Likewise. * coffdump.c (main): Likewise. * cxxfilt.c (main): Likewise. * dlltool.c (main): Likewise. * nlmconv.c (main): Likewise. * nm.c (main): Likewise. * objdump.c (main): Likewise. * size.c (main): Likewise. * srconv.c (main): Likewise. * strings.c (main): Likewise. * sysdump.c (main): Likewise. * windmc.c (main): Likewise. * windres.c (main): Likewise. * objcopy.c (main): Likewise. (copy_relocations_in_section): Check for relocs without associated symbol pointers.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog21
-rw-r--r--binutils/addr2line.c1
-rw-r--r--binutils/ar.c1
-rw-r--r--binutils/coffdump.c1
-rw-r--r--binutils/cxxfilt.c1
-rw-r--r--binutils/dlltool.c1
-rw-r--r--binutils/nlmconv.c1
-rw-r--r--binutils/nm.c1
-rw-r--r--binutils/objcopy.c13
-rw-r--r--binutils/objdump.c1
-rw-r--r--binutils/size.c1
-rw-r--r--binutils/srconv.c1
-rw-r--r--binutils/strings.c1
-rw-r--r--binutils/sysdump.c1
-rw-r--r--binutils/windmc.c1
-rw-r--r--binutils/windres.c1
16 files changed, 45 insertions, 3 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 78f0a20..1d1ba9d 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,24 @@
+2015-01-21 Nick Clifton <nickc@redhat.com>
+
+ PR binutils/17512
+ * addr2line.c (main): Call bfd_set_error_program_name.
+ * ar.c (main): Likewise.
+ * coffdump.c (main): Likewise.
+ * cxxfilt.c (main): Likewise.
+ * dlltool.c (main): Likewise.
+ * nlmconv.c (main): Likewise.
+ * nm.c (main): Likewise.
+ * objdump.c (main): Likewise.
+ * size.c (main): Likewise.
+ * srconv.c (main): Likewise.
+ * strings.c (main): Likewise.
+ * sysdump.c (main): Likewise.
+ * windmc.c (main): Likewise.
+ * windres.c (main): Likewise.
+ * objcopy.c (main): Likewise.
+ (copy_relocations_in_section): Check for relocs without associated
+ symbol pointers.
+
2015-01-21 Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
* MAINTAINERS: Add self to ARM maintainers list.
diff --git a/binutils/addr2line.c b/binutils/addr2line.c
index 9d2abe6..d37145e 100644
--- a/binutils/addr2line.c
+++ b/binutils/addr2line.c
@@ -423,6 +423,7 @@ main (int argc, char **argv)
program_name = *argv;
xmalloc_set_program_name (program_name);
+ bfd_set_error_program_name (program_name);
expandargv (&argc, &argv);
diff --git a/binutils/ar.c b/binutils/ar.c
index 48a052c..94c79e2 100644
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -691,6 +691,7 @@ main (int argc, char **argv)
program_name = argv[0];
xmalloc_set_program_name (program_name);
+ bfd_set_error_program_name (program_name);
#if BFD_SUPPORTS_PLUGINS
bfd_plugin_set_program_name (program_name);
#endif
diff --git a/binutils/coffdump.c b/binutils/coffdump.c
index 9883e22..90ce550 100644
--- a/binutils/coffdump.c
+++ b/binutils/coffdump.c
@@ -500,6 +500,7 @@ main (int ac, char **av)
program_name = av[0];
xmalloc_set_program_name (program_name);
+ bfd_set_error_program_name (program_name);
expandargv (&ac, &av);
diff --git a/binutils/cxxfilt.c b/binutils/cxxfilt.c
index 2daf33b..2da511f 100644
--- a/binutils/cxxfilt.c
+++ b/binutils/cxxfilt.c
@@ -176,6 +176,7 @@ main (int argc, char **argv)
program_name = argv[0];
xmalloc_set_program_name (program_name);
+ bfd_set_error_program_name (program_name);
expandargv (&argc, &argv);
diff --git a/binutils/dlltool.c b/binutils/dlltool.c
index 10204b0..dcc4651 100644
--- a/binutils/dlltool.c
+++ b/binutils/dlltool.c
@@ -4044,6 +4044,7 @@ main (int ac, char **av)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ bfd_set_error_program_name (program_name);
expandargv (&ac, &av);
while ((c = getopt_long (ac, av,
diff --git a/binutils/nlmconv.c b/binutils/nlmconv.c
index 8c4975d..ac41199 100644
--- a/binutils/nlmconv.c
+++ b/binutils/nlmconv.c
@@ -211,6 +211,7 @@ main (int argc, char **argv)
program_name = argv[0];
xmalloc_set_program_name (program_name);
+ bfd_set_error_program_name (program_name);
expandargv (&argc, &argv);
diff --git a/binutils/nm.c b/binutils/nm.c
index 76013df..a8f2f70 100644
--- a/binutils/nm.c
+++ b/binutils/nm.c
@@ -1570,6 +1570,7 @@ main (int argc, char **argv)
program_name = *argv;
xmalloc_set_program_name (program_name);
+ bfd_set_error_program_name (program_name);
#if BFD_SUPPORTS_PLUGINS
bfd_plugin_set_program_name (program_name);
#endif
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 9524bb8..8320793 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -2960,9 +2960,13 @@ copy_relocations_in_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
temp_relpp = (arelent **) xmalloc (relsize);
for (i = 0; i < relcount; i++)
- if (is_specified_symbol (bfd_asymbol_name (*relpp[i]->sym_ptr_ptr),
- keep_specific_htab))
- temp_relpp [temp_relcount++] = relpp [i];
+ {
+ /* PR 17512: file: 9e907e0c. */
+ if (relpp[i]->sym_ptr_ptr)
+ if (is_specified_symbol (bfd_asymbol_name (*relpp[i]->sym_ptr_ptr),
+ keep_specific_htab))
+ temp_relpp [temp_relcount++] = relpp [i];
+ }
relcount = temp_relcount;
free (relpp);
relpp = temp_relpp;
@@ -4411,6 +4415,9 @@ main (int argc, char *argv[])
create_symbol_htabs ();
+ if (argv != NULL)
+ bfd_set_error_program_name (argv[0]);
+
if (is_strip)
strip_main (argc, argv);
else
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 22e5ad6..54fc235 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -3495,6 +3495,7 @@ main (int argc, char **argv)
program_name = *argv;
xmalloc_set_program_name (program_name);
+ bfd_set_error_program_name (program_name);
START_PROGRESS (program_name, 0);
diff --git a/binutils/size.c b/binutils/size.c
index 465603f..dcfd954 100644
--- a/binutils/size.c
+++ b/binutils/size.c
@@ -133,6 +133,7 @@ main (int argc, char **argv)
program_name = *argv;
xmalloc_set_program_name (program_name);
+ bfd_set_error_program_name (program_name);
expandargv (&argc, &argv);
diff --git a/binutils/srconv.c b/binutils/srconv.c
index c19c0ed..63c6940 100644
--- a/binutils/srconv.c
+++ b/binutils/srconv.c
@@ -1774,6 +1774,7 @@ main (int ac, char **av)
program_name = av[0];
xmalloc_set_program_name (program_name);
+ bfd_set_error_program_name (program_name);
expandargv (&ac, &av);
diff --git a/binutils/strings.c b/binutils/strings.c
index 8f215e5..0e2c9a8 100644
--- a/binutils/strings.c
+++ b/binutils/strings.c
@@ -164,6 +164,7 @@ main (int argc, char **argv)
program_name = argv[0];
xmalloc_set_program_name (program_name);
+ bfd_set_error_program_name (program_name);
expandargv (&argc, &argv);
diff --git a/binutils/sysdump.c b/binutils/sysdump.c
index ac350e1..177262c 100644
--- a/binutils/sysdump.c
+++ b/binutils/sysdump.c
@@ -686,6 +686,7 @@ main (int ac, char **av)
program_name = av[0];
xmalloc_set_program_name (program_name);
+ bfd_set_error_program_name (program_name);
expandargv (&ac, &av);
diff --git a/binutils/windmc.c b/binutils/windmc.c
index 5fd8cd5..c78ae1f 100644
--- a/binutils/windmc.c
+++ b/binutils/windmc.c
@@ -952,6 +952,7 @@ main (int argc, char **argv)
program_name = argv[0];
xmalloc_set_program_name (program_name);
+ bfd_set_error_program_name (program_name);
expandargv (&argc, &argv);
diff --git a/binutils/windres.c b/binutils/windres.c
index 00939b0..2fed128 100644
--- a/binutils/windres.c
+++ b/binutils/windres.c
@@ -808,6 +808,7 @@ main (int argc, char **argv)
program_name = argv[0];
xmalloc_set_program_name (program_name);
+ bfd_set_error_program_name (program_name);
expandargv (&argc, &argv);