Prevent an infinite recursion when a plugin tries to claim a file in an unrecognised format.

Resolves: #1174065
This commit is contained in:
Nick Clifton 2015-11-05 16:31:21 +00:00
parent b39776830b
commit 58ff635f1e
2 changed files with 69 additions and 1 deletions

View File

@ -0,0 +1,60 @@
diff -rup binutils-2.25.1.orig/bfd/plugin.c binutils-2.25.1/bfd/plugin.c
--- binutils-2.25.1.orig/bfd/plugin.c 2015-11-05 11:40:58.400941923 +0000
+++ binutils-2.25.1/bfd/plugin.c 2015-11-05 15:50:37.046908541 +0000
@@ -135,8 +135,9 @@ static asection bfd_plugin_fake_common_s
= BFD_FAKE_SECTION (bfd_plugin_fake_common_section, SEC_IS_COMMON, 0,
NULL, 0);
-/* Get symbols from object only section. */
+static bfd_boolean in_get_symbols = FALSE;
+/* Get symbols from object only section. */
static void
bfd_plugin_get_symbols_in_object_only (bfd *abfd)
{
@@ -153,7 +154,8 @@ bfd_plugin_get_symbols_in_object_only (b
if (abfd->sections == NULL && abfd->my_archive == NULL)
{
nbfd = bfd_openr (abfd->filename, NULL);
- if (nbfd == NULL || !bfd_check_format (nbfd, bfd_object))
+
+ if (nbfd == NULL)
{
(*_bfd_error_handler)
(_("%s: failed to open to extract object only section: %s"),
@@ -161,6 +163,22 @@ bfd_plugin_get_symbols_in_object_only (b
bfd_close (nbfd);
return;
}
+ else
+ {
+ /* Note that we are calling bfd_check_format from inside
+ bfd_plugin_get_symbols_in_object_only. bfd_check_format
+ will iterate through the known list of formats, including
+ the "plugin" format, and we do not want to end up in a
+ recursive loop. */
+ in_get_symbols = TRUE;
+ if (!bfd_check_format (nbfd, bfd_object))
+ {
+ in_get_symbols = FALSE;
+ bfd_close (nbfd);
+ return;
+ }
+ in_get_symbols = FALSE;
+ }
}
else
{
@@ -450,6 +468,12 @@ load_plugin (bfd *abfd)
static const bfd_target *
bfd_plugin_object_p (bfd *abfd)
{
+ /* If in_get_symbols is TRUE then this function is being called from
+ bfd_check_format. We do not want to iterate again - we will just
+ end up in an infinite loop. So return NULL here. */
+ if (in_get_symbols)
+ return NULL;
+
if (!load_plugin (abfd))
return NULL;

View File

@ -20,7 +20,7 @@
Summary: A GNU collection of binary utilities
Name: %{?cross}binutils%{?_with_debug:-debug}
Version: 2.25.1
Release: 8%{?dist}
Release: 9%{?dist}
License: GPLv3+
Group: Development/Tools
URL: http://sources.redhat.com/binutils
@ -61,6 +61,8 @@ Patch16: binutils-2.25.1-dynamic_list.patch
Patch17: binutils-2.25.1-aarch64-pr18668.patch
# Fix incorrectly generated ELF binaries and DSOs
Patch18: binutils-rh1247126.patch
# Fix infinite recursion when a plugin tries to claim an unrecognized binary
Patch19: binutils-2.25.1-plugin-format-checking.patch
Provides: bundled(libiberty)
@ -187,6 +189,7 @@ using libelf instead of BFD.
%patch16 -p1 -b .dynamic_list~
%patch17 -p1
%patch18 -p1
%patch19 -p1
# We cannot run autotools as there is an exact requirement of autoconf-2.59.
@ -506,6 +509,10 @@ exit 0
%endif # %{isnative}
%changelog
* Thu Nov 05 2015 Nick Clifton <nickc@redhat.com> 2.25.1-9
- Prevent an infinite recursion when a plugin tries to claim a file in an unrecognised format.
(#1174065)
* Wed Oct 28 2015 Nick Clifton <nickc@redhat.com> 2.25.1-8
- Enable little endian support when configuring for 64-bit PowerPC.
(#1275709)
@ -2271,3 +2278,4 @@ exit 0
* Wed Oct 22 1997 Erik Troan <ewt@redhat.com>
- added 2.8.1.0.1 patch from hj
- added patch for alpha palcode form rth