]> git.pld-linux.org Git - packages/binutils.git/commitdiff
- rel 2; Close resource leaks in the BFD library's plugin handler. https://sourceware...
authorBartek Szady <bszx@bszx.eu>
Sat, 4 Aug 2018 07:44:43 +0000 (09:44 +0200)
committerBartek Szady <bszx@bszx.eu>
Sat, 4 Aug 2018 07:48:56 +0000 (09:48 +0200)
binutils.spec
fd-leak.patch [new file with mode: 0644]

index 1a8273c790785a0e46f0b70cac308b899f1d0da3..01dc57d723dbb6fc81d6ccf676ed6f4f43cc5c4d 100644 (file)
@@ -24,7 +24,7 @@ Summary(tr.UTF-8):    GNU geliştirme araçları
 Summary(uk.UTF-8):     Набір інструментів GNU для побудови виконуваних програм
 Name:          binutils
 Version:       2.31.1
-Release:       1
+Release:       2
 Epoch:         4
 License:       GPL v3+
 Group:         Development/Tools
@@ -45,6 +45,7 @@ Patch9:               %{name}-tooldir.patch
 Patch10:       %{name}-sanity-check.patch
 # https://bugzilla.redhat.com/show_bug.cgi?id=1599521
 Patch11:       binutils-do-not-provide-shared-section-symbols.patch
+Patch12:       fd-leak.patch
 URL:           http://sources.redhat.com/binutils/
 BuildRequires: autoconf >= 2.64
 BuildRequires: automake >= 1:1.11
@@ -174,6 +175,7 @@ niektórych pakietów.
 %patch9 -p1
 %patch10 -p1
 %patch11 -p1
+%patch12 -p1
 
 # file contains hacks for ac 2.59 only
 %{__rm} config/override.m4
diff --git a/fd-leak.patch b/fd-leak.patch
new file mode 100644 (file)
index 0000000..6a89bac
--- /dev/null
@@ -0,0 +1,118 @@
+commit b339543c6cac043f087b51fd859186e77f757f85
+Author: Nick Clifton <nickc@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@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@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;
This page took 0.143525 seconds and 4 git commands to generate.