[packages/binutils] - up to 2.32 (pax disabled - we have no grsec kernels anymore; info patch disabled (what's the point

arekm arekm at pld-linux.org
Tue Jun 4 13:36:40 CEST 2019


commit 46bb88534583af2e8c64293f88b7b4a90d8be9aa
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Tue Jun 4 13:36:26 2019 +0200

    - up to 2.32 (pax disabled - we have no grsec kernels anymore; info patch disabled (what's the point of it?); cve patches from fedora

 binutils-CVE-2019-9071.patch | 110 ++++++++++++++++++++++++++++++
 binutils-CVE-2019-9073.patch |  13 ++++
 binutils-CVE-2019-9074.patch |  32 +++++++++
 binutils-CVE-2019-9075.patch |  73 ++++++++++++++++++++
 binutils-CVE-2019-9077.patch |  16 +++++
 binutils-bug-23499.patch     | 157 -------------------------------------------
 binutils.spec                |  21 ++++--
 fd-leak.patch                | 118 --------------------------------
 8 files changed, 258 insertions(+), 282 deletions(-)
---
diff --git a/binutils.spec b/binutils.spec
index 5b661e7..a52f095 100644
--- a/binutils.spec
+++ b/binutils.spec
@@ -3,7 +3,7 @@
 %bcond_with	allarchs	# enable all targets
 # define addtargets x,y,z	# build with additional targets x,y,z (e.g. x86_64-linux)
 				# http://sourceware.org/ml/binutils/2008-03/msg00162.html
-%bcond_without	pax		# without PaX flags (for upstream bugreports)
+%bcond_with	pax		# without PaX flags (for upstream bugreports)
 %bcond_without	gold		# don't build gold (no C++ dependencies)
 %bcond_without	default_bfd	# default ld.bfd instead of gold
 %bcond_without	gasp		# gasp
@@ -23,13 +23,13 @@ Summary(ru.UTF-8):	Набор инструментов GNU для построе
 Summary(tr.UTF-8):	GNU geliştirme araçları
 Summary(uk.UTF-8):	Набір інструментів GNU для побудови виконуваних програм
 Name:		binutils
-Version:	2.31.1
-Release:	4
+Version:	2.32
+Release:	1
 Epoch:		4
 License:	GPL v3+
 Group:		Development/Tools
 Source0:	http://ftp.gnu.org/gnu/binutils/%{name}-%{version}.tar.lz
-# Source0-md5:	a517a836dd5747cc9e64d81addc517ad
+# Source0-md5:	3f1013fc8c5b18e1c28ba5c018a4110c
 Source1:	http://www.mif.pg.gda.pl/homepages/ankry/man-PLD/%{name}-non-english-man-pages.tar.bz2
 # Source1-md5:	a717d9707ec77d82acb6ec9078c472d6
 Patch0:		%{name}-gasp.patch
@@ -43,8 +43,11 @@ Patch7:		%{name}-libtool-m.patch
 Patch8:		%{name}-build-id.patch
 Patch9:		%{name}-tooldir.patch
 Patch10:	%{name}-sanity-check.patch
-Patch11:	binutils-bug-23499.patch
-Patch12:	fd-leak.patch
+Patch11:	binutils-CVE-2019-9071.patch
+Patch12:	binutils-CVE-2019-9073.patch
+Patch13:	binutils-CVE-2019-9074.patch
+Patch14:	binutils-CVE-2019-9075.patch
+Patch15:	binutils-CVE-2019-9077.patch
 URL:		http://sources.redhat.com/binutils/
 BuildRequires:	autoconf >= 2.64
 BuildRequires:	automake >= 1:1.11
@@ -163,7 +166,7 @@ niektórych pakietów.
 %prep
 %setup -q
 %{?with_gasp:%patch0 -p1}
-%patch1 -p1
+#%patch1 -p1
 %patch2 -p1
 %{?with_pax:%patch3 -p1}
 %patch4 -p1
@@ -175,6 +178,9 @@ niektórych pakietów.
 %patch10 -p1
 %patch11 -p1
 %patch12 -p1
+%patch13 -p1
+%patch14 -p1
+%patch15 -p1
 
 # file contains hacks for ac 2.59 only
 %{__rm} config/override.m4
@@ -379,6 +385,7 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/libiberty.a
 %{_includedir}/ansidecl.h
 %{_includedir}/bfd.h
+%{_includedir}/bfd_stdint.h
 %{_includedir}/bfdlink.h
 %{_includedir}/diagnostics.h
 %{_includedir}/dis-asm.h
diff --git a/binutils-CVE-2019-9071.patch b/binutils-CVE-2019-9071.patch
new file mode 100644
index 0000000..f4ef3bc
--- /dev/null
+++ b/binutils-CVE-2019-9071.patch
@@ -0,0 +1,110 @@
+--- binutils.orig/libiberty/cp-demangle.c	2019-04-10 10:31:27.854997707 +0100
++++ binutils-2.31.1/libiberty/cp-demangle.c	2019-04-10 16:00:35.820350978 +0100
+@@ -858,7 +858,7 @@ CP_STATIC_IF_GLIBCPP_V3
+ int
+ cplus_demangle_fill_name (struct demangle_component *p, const char *s, int len)
+ {
+-  if (p == NULL || s == NULL || len == 0)
++  if (p == NULL || s == NULL || len <= 0)
+     return 0;
+   p->d_printing = 0;
+   p->type = DEMANGLE_COMPONENT_NAME;
+@@ -4032,7 +4032,7 @@ d_growable_string_callback_adapter (cons
+    are larger than the actual numbers encountered.  */
+ 
+ static void
+-d_count_templates_scopes (int *num_templates, int *num_scopes,
++d_count_templates_scopes (struct d_print_info *dpi,
+ 			  const struct demangle_component *dc)
+ {
+   if (dc == NULL)
+@@ -4052,13 +4052,13 @@ d_count_templates_scopes (int *num_templ
+       break;
+ 
+     case DEMANGLE_COMPONENT_TEMPLATE:
+-      (*num_templates)++;
++      dpi->num_copy_templates++;
+       goto recurse_left_right;
+ 
+     case DEMANGLE_COMPONENT_REFERENCE:
+     case DEMANGLE_COMPONENT_RVALUE_REFERENCE:
+       if (d_left (dc)->type == DEMANGLE_COMPONENT_TEMPLATE_PARAM)
+-	(*num_scopes)++;
++	dpi->num_saved_scopes++;
+       goto recurse_left_right;
+ 
+     case DEMANGLE_COMPONENT_QUAL_NAME:
+@@ -4122,42 +4122,42 @@ d_count_templates_scopes (int *num_templ
+     case DEMANGLE_COMPONENT_TAGGED_NAME:
+     case DEMANGLE_COMPONENT_CLONE:
+     recurse_left_right:
+-      d_count_templates_scopes (num_templates, num_scopes,
+-				d_left (dc));
+-      d_count_templates_scopes (num_templates, num_scopes,
+-				d_right (dc));
++      /* PR 89394 - Check for too much recursion.  */
++      if (dpi->recursion > DEMANGLE_RECURSION_LIMIT)
++	/* FIXME: There ought to be a way to report to the
++	   user that the recursion limit has been reached.  */
++	return;
++
++      ++ dpi->recursion;
++      d_count_templates_scopes (dpi, d_left (dc));
++      d_count_templates_scopes (dpi, d_right (dc));
++      -- dpi->recursion;
+       break;
+ 
+     case DEMANGLE_COMPONENT_CTOR:
+-      d_count_templates_scopes (num_templates, num_scopes,
+-				dc->u.s_ctor.name);
++      d_count_templates_scopes (dpi, dc->u.s_ctor.name);
+       break;
+ 
+     case DEMANGLE_COMPONENT_DTOR:
+-      d_count_templates_scopes (num_templates, num_scopes,
+-				dc->u.s_dtor.name);
++      d_count_templates_scopes (dpi, dc->u.s_dtor.name);
+       break;
+ 
+     case DEMANGLE_COMPONENT_EXTENDED_OPERATOR:
+-      d_count_templates_scopes (num_templates, num_scopes,
+-				dc->u.s_extended_operator.name);
++      d_count_templates_scopes (dpi, dc->u.s_extended_operator.name);
+       break;
+ 
+     case DEMANGLE_COMPONENT_FIXED_TYPE:
+-      d_count_templates_scopes (num_templates, num_scopes,
+-                                dc->u.s_fixed.length);
++      d_count_templates_scopes (dpi, dc->u.s_fixed.length);
+       break;
+ 
+     case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS:
+     case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS:
+-      d_count_templates_scopes (num_templates, num_scopes,
+-				d_left (dc));
++      d_count_templates_scopes (dpi, d_left (dc));
+       break;
+ 
+     case DEMANGLE_COMPONENT_LAMBDA:
+     case DEMANGLE_COMPONENT_DEFAULT_ARG:
+-      d_count_templates_scopes (num_templates, num_scopes,
+-				dc->u.s_unary_num.sub);
++      d_count_templates_scopes (dpi, dc->u.s_unary_num.sub);
+       break;
+     }
+ }
+@@ -4192,8 +4192,12 @@ d_print_init (struct d_print_info *dpi,
+   dpi->next_copy_template = 0;
+   dpi->num_copy_templates = 0;
+ 
+-  d_count_templates_scopes (&dpi->num_copy_templates,
+-			    &dpi->num_saved_scopes, dc);
++  d_count_templates_scopes (dpi, dc);
++  /* If we did not reach the recursion limit, then reset the
++     current recursion value back to 0, so that we can print
++     the templates.  */
++  if (dpi->recursion < DEMANGLE_RECURSION_LIMIT)
++    dpi->recursion = 0;
+   dpi->num_copy_templates *= dpi->num_saved_scopes;
+ 
+   dpi->current_template = NULL;
diff --git a/binutils-CVE-2019-9073.patch b/binutils-CVE-2019-9073.patch
new file mode 100644
index 0000000..37256f4
--- /dev/null
+++ b/binutils-CVE-2019-9073.patch
@@ -0,0 +1,13 @@
+--- binutils.orig/binutils/objdump.c	2019-02-25 16:12:30.394056901 +0000
++++ binutils-2.31.1/binutils/objdump.c	2019-02-25 16:13:07.224778005 +0000
+@@ -2993,7 +2993,9 @@ dump_bfd_header (bfd *abfd)
+ static void
+ dump_bfd_private_header (bfd *abfd)
+ {
+-  bfd_print_private_bfd_data (abfd, stdout);
++  if (!bfd_print_private_bfd_data (abfd, stdout))
++    non_fatal (_("warning: private headers incomplete: %s"),
++              bfd_errmsg (bfd_get_error ()));
+ }
+ 
+ static void
diff --git a/binutils-CVE-2019-9074.patch b/binutils-CVE-2019-9074.patch
new file mode 100644
index 0000000..84f0fd5
--- /dev/null
+++ b/binutils-CVE-2019-9074.patch
@@ -0,0 +1,32 @@
+--- binutils.orig/bfd/pei-x86_64.c	2019-02-25 16:12:29.798061414 +0000
++++ binutils-2.31.1/bfd/pei-x86_64.c	2019-02-25 17:09:02.783425236 +0000
+@@ -541,7 +541,7 @@ pex64_bfd_print_pdata_section (bfd *abfd
+   /* virt_size might be zero for objects.  */
+   if (stop == 0 && strcmp (abfd->xvec->name, "pe-x86-64") == 0)
+     {
+-      stop = (datasize / onaline) * onaline;
++      stop = datasize;
+       virt_size_is_zero = TRUE;
+     }
+   else if (datasize < stop)
+@@ -551,8 +551,8 @@ pex64_bfd_print_pdata_section (bfd *abfd
+ 		 _("Warning: %s section size (%ld) is smaller than virtual size (%ld)\n"),
+ 		 pdata_section->name, (unsigned long) datasize,
+ 		 (unsigned long) stop);
+-	/* Be sure not to read passed datasize.  */
+-	stop = datasize / onaline;
++	/* Be sure not to read past datasize.  */
++	stop = datasize;
+       }
+ 
+   /* Display functions table.  */
+@@ -724,8 +724,7 @@ pex64_bfd_print_pdata_section (bfd *abfd
+ 	      altent += imagebase;
+ 
+ 	      if (altent >= pdata_vma
+-		  && (altent + PDATA_ROW_SIZE <= pdata_vma
+-		      + pei_section_data (abfd, pdata_section)->virt_size))
++		  && altent - pdata_vma + PDATA_ROW_SIZE <= stop)
+ 		{
+ 		  pex64_get_runtime_function
+ 		    (abfd, &arf, &pdata[altent - pdata_vma]);
diff --git a/binutils-CVE-2019-9075.patch b/binutils-CVE-2019-9075.patch
new file mode 100644
index 0000000..ec3e8ca
--- /dev/null
+++ b/binutils-CVE-2019-9075.patch
@@ -0,0 +1,73 @@
+diff -rup binutils.orig/bfd/archive64.c binutils-2.31.1/bfd/archive64.c
+--- binutils.orig/bfd/archive64.c	2019-02-26 11:17:11.882530151 +0000
++++ binutils-2.31.1/bfd/archive64.c	2019-02-26 11:19:18.422488805 +0000
+@@ -100,8 +100,6 @@ _bfd_archive_64_bit_slurp_armap (bfd *ab
+     return FALSE;
+   carsyms = ardata->symdefs;
+   stringbase = ((char *) ardata->symdefs) + carsym_size;
+-  stringbase[stringsize] = 0;
+-  stringend = stringbase + stringsize;
+ 
+   raw_armap = (bfd_byte *) bfd_alloc (abfd, ptrsize);
+   if (raw_armap == NULL)
+@@ -115,15 +113,17 @@ _bfd_archive_64_bit_slurp_armap (bfd *ab
+       goto release_raw_armap;
+     }
+ 
++  stringend = stringbase + stringsize;
++  *stringend = 0;
+   for (i = 0; i < nsymz; i++)
+     {
+       carsyms->file_offset = bfd_getb64 (raw_armap + i * 8);
+       carsyms->name = stringbase;
+-      if (stringbase < stringend)
+-	stringbase += strlen (stringbase) + 1;
++      stringbase += strlen (stringbase);
++      if (stringbase != stringend)
++	++stringbase;
+       ++carsyms;
+     }
+-  *stringbase = '\0';
+ 
+   ardata->symdef_count = nsymz;
+   ardata->first_file_filepos = bfd_tell (abfd);
+diff -rup binutils.orig/bfd/archive.c binutils-2.31.1/bfd/archive.c
+--- binutils.orig/bfd/archive.c	2019-02-26 11:17:11.884530134 +0000
++++ binutils-2.31.1/bfd/archive.c	2019-02-26 11:18:33.354859687 +0000
+@@ -1014,6 +1014,7 @@ do_slurp_coff_armap (bfd *abfd)
+   int *raw_armap, *rawptr;
+   struct artdata *ardata = bfd_ardata (abfd);
+   char *stringbase;
++  char *stringend;
+   bfd_size_type stringsize;
+   bfd_size_type parsed_size;
+   carsym *carsyms;
+@@ -1073,22 +1074,20 @@ do_slurp_coff_armap (bfd *abfd)
+     }
+ 
+   /* OK, build the carsyms.  */
+-  for (i = 0; i < nsymz && stringsize > 0; i++)
++  stringend = stringbase + stringsize;
++  *stringend = 0;
++  for (i = 0; i < nsymz; i++)
+     {
+       bfd_size_type len;
+ 
+       rawptr = raw_armap + i;
+       carsyms->file_offset = swap ((bfd_byte *) rawptr);
+       carsyms->name = stringbase;
+-      /* PR 17512: file: 4a1d50c1.  */
+-      len = strnlen (stringbase, stringsize);
+-      if (len < stringsize)
+-	len ++;
+-      stringbase += len;
+-      stringsize -= len;
++      stringbase += strlen (stringbase);
++      if (stringbase != stringend)
++	++stringbase;
+       carsyms++;
+     }
+-  *stringbase = 0;
+ 
+   ardata->symdef_count = nsymz;
+   ardata->first_file_filepos = bfd_tell (abfd);
diff --git a/binutils-CVE-2019-9077.patch b/binutils-CVE-2019-9077.patch
new file mode 100644
index 0000000..1790bfa
--- /dev/null
+++ b/binutils-CVE-2019-9077.patch
@@ -0,0 +1,16 @@
+--- binutils.orig/binutils/readelf.c	2019-02-26 11:17:12.414525772 +0000
++++ binutils-2.31.1/binutils/readelf.c	2019-02-26 12:11:40.642876742 +0000
+@@ -16009,6 +16009,13 @@ process_mips_specific (Filedata * fileda
+ 	  return FALSE;
+ 	}
+ 
++      /* PR 24243  */
++      if (sect->sh_size < sizeof (* eopt))
++	{
++	  error (_("The MIPS options section is too small.\n"));
++	  return FALSE;
++	}
++
+       eopt = (Elf_External_Options *) get_data (NULL, filedata, options_offset, 1,
+                                                 sect->sh_size, _("options"));
+       if (eopt)
diff --git a/binutils-bug-23499.patch b/binutils-bug-23499.patch
deleted file mode 100644
index 1715acf..0000000
--- a/binutils-bug-23499.patch
+++ /dev/null
@@ -1,157 +0,0 @@
-commit 48e30f5238c70e738f44474d595c476ef4e4ec38
-Author: H.J. Lu <hjl.tools at gmail.com>
-Date:   Fri Aug 10 12:21:58 2018 -0700
-
-    Always clear h->verinfo.verdef when overriding a dynamic definition
-    
-    When linker defines a symbol to override a dynamic definition, it should
-    always clear h->verinfo.verdef so that the symbol won't be associated
-    with the version information from the dynamic object.  This happened to
-    the symbol "_edata" when creating an unversioned dynamic object linking
-    against:
-    
-    1. libKF5ConfigCore.so.5.49.0
-    2. libKF5CoreAddons.so.5.49.0
-    3. libKF5I18n.so.5.49.0
-    4. libKF5DBusAddons.so.5.49.0
-    5. libQt5Xml.so.5.11.1
-    6. libQt5DBus.so.5.11.1
-    7. libQt5Core.so.5.11.1
-    
-    Among them
-    
-    libQt5Xml.so.5.11.1
-       299: 000000000003e000     0 NOTYPE  GLOBAL DEFAULT   18 _edata@@Qt_5
-    libQt5DBus.so.5.11.1
-       597: 0000000000092018     0 NOTYPE  GLOBAL DEFAULT   18 _edata@@Qt_5
-    libQt5Core.so.5.11.1
-      2292: 00000000004df640     0 NOTYPE  GLOBAL DEFAULT   21 _edata at Qt_5
-      2293: 00000000004df640     0 NOTYPE  GLOBAL DEFAULT   21 _edata at Qt_5
-    
-    The problem is triggered by 2 duplicated entries of _edata at Qt_5 in
-    libQt5Core.so.5.11.1 which was created by gold.  Before this commit,
-    ld created the dynamic object with "_edata" in its dynamic symbol table
-    which was linker defined and associated with the version information
-    from libQt5Core.so.5.11.1.  The code in question was there when the
-    binutils source was imported to sourceware.org.  When such a dynamic
-    object was used later, we got:
-    
-    /usr/bin/ld: bin/libKF5Service.so.5.49.0: _edata: invalid version 21 (max 0)
-    /usr/bin/ld: bin/libKF5Service.so.5.49.0: error adding symbols: bad value
-    
-    Tested with many ELF targets.
-    
-            PR ld/23499
-            * elflink.c (bfd_elf_record_link_assignment): Always clear
-            h->verinfo.verdef when overriding a dynamic definition.
-
-diff --git a/bfd/elflink.c b/bfd/elflink.c
-index b24fb95848..02618bed8f 100644
---- a/bfd/elflink.c
-+++ b/bfd/elflink.c
-@@ -686,13 +686,11 @@ bfd_elf_record_link_assignment (bfd *output_bfd,
-       && !h->def_regular)
-     h->root.type = bfd_link_hash_undefined;
- 
--  /* If this symbol is not being provided by the linker script, and it is
--     currently defined by a dynamic object, but not by a regular object,
--     then clear out any version information because the symbol will not be
--     associated with the dynamic object any more.  */
--  if (!provide
--      && h->def_dynamic
--      && !h->def_regular)
-+  /* If this symbol is currently defined by a dynamic object, but not
-+     by a regular object, then clear out any version information because
-+     the symbol will not be associated with the dynamic object any
-+     more.  */
-+  if (h->def_dynamic && !h->def_regular)
-     h->verinfo.verdef = NULL;
- 
-   /* Make sure this symbol is not garbage collected.  */
-commit 7a815dd566f3dd32435ac73aa0a0cc948d525e06
-Author: H.J. Lu <hjl.tools at gmail.com>
-Date:   Sat Aug 25 06:17:52 2018 -0700
-
-    elf: Check for corrupt symbol version info
-    
-    The BFD linker with PR ld/23499 may generate shared libraries with
-    corrupt symbol version info which leads to linker error when the
-    corrupt shared library is used:
-    
-    /usr/bin/ld: bin/libKF5Service.so.5.49.0: _edata: invalid version 21 (max 0)
-    /usr/bin/ld: bin/libKF5Service.so.5.49.0: error adding symbols: bad value
-    
-    Add check for corrupt symbol version info to objdump:
-    
-    00000000000af005 g    D  .data  0000000000000000  <corrupt>   _edata
-    
-    and readelf:
-    
-       728: 00000000000af005     0 NOTYPE  GLOBAL DEFAULT   25 _edata@<corrupt> (5)
-    
-    bfd/
-    
-            PR ld/23499
-            * elf.c (_bfd_elf_get_symbol_version_string): Return
-            _("<corrupt>") for corrupt symbol version info.
-    
-    binutils/
-    
-            PR ld/23499
-            * readelf.c (get_symbol_version_string): Return _("<corrupt>")
-            for corrupt symbol version info.
-
-diff --git a/bfd/elf.c b/bfd/elf.c
-index efdaf2e256..b8860c453b 100644
---- a/bfd/elf.c
-+++ b/bfd/elf.c
-@@ -1877,7 +1877,7 @@ _bfd_elf_get_symbol_version_string (bfd *abfd, asymbol *symbol,
- 	{
- 	  Elf_Internal_Verneed *t;
- 
--	  version_string = "";
-+	  version_string = _("<corrupt>");
- 	  for (t = elf_tdata (abfd)->verref;
- 	       t != NULL;
- 	       t = t->vn_nextref)
-diff --git a/binutils/readelf.c b/binutils/readelf.c
-index 8d4054fbd2..23e61d369a 100644
---- a/binutils/readelf.c
-+++ b/binutils/readelf.c
-@@ -11300,6 +11300,7 @@ get_symbol_version_string (Filedata *                   filedata,
-   unsigned char data[2];
-   unsigned short vers_data;
-   unsigned long offset;
-+  unsigned short max_vd_ndx;
- 
-   if (!is_dynsym
-       || version_info[DT_VERSIONTAGIDX (DT_VERSYM)] == 0)
-@@ -11317,6 +11318,8 @@ get_symbol_version_string (Filedata *                   filedata,
-   if ((vers_data & VERSYM_HIDDEN) == 0 && vers_data == 0)
-     return NULL;
- 
-+  max_vd_ndx = 0;
-+
-   /* Usually we'd only see verdef for defined symbols, and verneed for
-      undefined symbols.  However, symbols defined by the linker in
-      .dynbss for variables copied from a shared library in order to
-@@ -11359,6 +11362,9 @@ get_symbol_version_string (Filedata *                   filedata,
- 	      ivd.vd_flags = BYTE_GET (evd.vd_flags);
- 	    }
- 
-+	  if ((ivd.vd_ndx & VERSYM_VERSION) > max_vd_ndx)
-+	    max_vd_ndx = ivd.vd_ndx & VERSYM_VERSION;
-+
- 	  off += ivd.vd_next;
- 	}
-       while (ivd.vd_ndx != (vers_data & VERSYM_VERSION) && ivd.vd_next != 0);
-@@ -11450,6 +11456,9 @@ get_symbol_version_string (Filedata *                   filedata,
- 	  return (ivna.vna_name < strtab_size
- 		  ? strtab + ivna.vna_name : _("<corrupt>"));
- 	}
-+      else if ((max_vd_ndx || (vers_data & VERSYM_VERSION) != 1)
-+	       && (vers_data & VERSYM_VERSION) > max_vd_ndx)
-+	return _("<corrupt>");
-     }
-   return NULL;
- }
diff --git a/fd-leak.patch b/fd-leak.patch
deleted file mode 100644
index 6a89bac..0000000
--- a/fd-leak.patch
+++ /dev/null
@@ -1,118 +0,0 @@
-commit b339543c6cac043f087b51fd859186e77f757f85
-Author: Nick Clifton <nickc at redhat.com>
-Date:   Wed Aug 1 14:34:41 2018 +0100
-
-    Close resource leaks in the BFD library's plugin handler.
-    
-            PR 23460
-            * plugin.c (bfd_plugin_open_input): Close file descriptor if the
-            call to fstat fails.
-            (try_claim): Always close the file descriptor at the end of the
-            function.
-            (try_load_plugin): If a plugin has already been registered, then
-            skip the dlopen and onload steps and go straight to claiming the
-            file.  If these is an error, close the plugin.
-
-diff --git a/bfd/ChangeLog b/bfd/ChangeLog
-index d3831b7a65..457c00e6bd 100644
---- a/bfd/ChangeLog
-+++ b/bfd/ChangeLog
-@@ -1,3 +1,14 @@
-+2018-08-01  Zenith  <zenith432 at users.sourceforge.net>
-+
-+	PR 23460
-+	* plugin.c (bfd_plugin_open_input): Close file descriptor if the
-+	call to fstat fails.
-+	(try_claim): Always close the file descriptor at the end of the
-+	function.
-+	(try_load_plugin): If a plugin has already been registered, then
-+	skip the dlopen and onload steps and go straight to claiming the
-+	file.  If these is an error, close the plugin.
-+
- 2018-07-18  Nick Clifton  <nickc at redhat.com>
- 
- 	2.31.1 Release point.
-diff --git a/bfd/plugin.c b/bfd/plugin.c
-index 7c5bba22c7..d9b9e2f174 100644
---- a/bfd/plugin.c
-+++ b/bfd/plugin.c
-@@ -124,7 +124,7 @@ message (int level ATTRIBUTE_UNUSED,
- }
- 
- /* Register a claim-file handler. */
--static ld_plugin_claim_file_handler claim_file;
-+static ld_plugin_claim_file_handler claim_file = NULL;
- 
- static enum ld_plugin_status
- register_claim_file (ld_plugin_claim_file_handler handler)
-@@ -186,8 +186,13 @@ bfd_plugin_open_input (bfd *ibfd, struct ld_plugin_input_file *file)
-   if (iobfd == ibfd)
-     {
-       struct stat stat_buf;
-+
-       if (fstat (file->fd, &stat_buf))
--	return 0;
-+	{
-+	  close(file->fd);
-+	  return 0;
-+	}
-+
-       file->offset = 0;
-       file->filesize = stat_buf.st_size;
-     }
-@@ -208,21 +213,24 @@ try_claim (bfd *abfd)
-   file.handle = abfd;
-   if (!bfd_plugin_open_input (abfd, &file))
-     return 0;
--  claim_file (&file, &claimed);
--  if (!claimed)
--    close (file.fd);
-+  if (claim_file)
-+    claim_file (&file, &claimed);
-+  close (file.fd);
-   return claimed;
- }
- 
- static int
- try_load_plugin (const char *pname, bfd *abfd, int *has_plugin_p)
- {
--  void *plugin_handle;
-+  void *plugin_handle = NULL;
-   struct ld_plugin_tv tv[4];
-   int i;
-   ld_plugin_onload onload;
-   enum ld_plugin_status status;
- 
-+  if (claim_file)
-+    goto have_claim_file;
-+
-   *has_plugin_p = 0;
- 
-   plugin_handle = dlopen (pname, RTLD_NOW);
-@@ -257,6 +265,7 @@ try_load_plugin (const char *pname, bfd *abfd, int *has_plugin_p)
-   if (status != LDPS_OK)
-     goto err;
- 
-+have_claim_file:
-   *has_plugin_p = 1;
- 
-   abfd->plugin_format = bfd_plugin_no;
-@@ -272,6 +281,9 @@ try_load_plugin (const char *pname, bfd *abfd, int *has_plugin_p)
-   return 1;
- 
-  err:
-+  if (plugin_handle)
-+    dlclose (plugin_handle);
-+  register_claim_file (NULL);
-   return 0;
- }
- 
-@@ -362,7 +374,7 @@ load_plugin (bfd *abfd)
-       int valid_plugin;
- 
-       full_name = concat (p, "/", ent->d_name, NULL);
--      if (stat(full_name, &s) == 0 && S_ISREG (s.st_mode))
-+      if (stat (full_name, &s) == 0 && S_ISREG (s.st_mode))
- 	found = try_load_plugin (full_name, abfd, &valid_plugin);
-       if (has_plugin <= 0)
- 	has_plugin = valid_plugin;
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/binutils.git/commitdiff/46bb88534583af2e8c64293f88b7b4a90d8be9aa



More information about the pld-cvs-commit mailing list