summaryrefslogtreecommitdiffstats
path: root/0001-PR25447.patch
blob: 9f249395f4442ff5ca6ba3bcaee88f4a0fe1b350 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
From 82f439d028c65663a0baf0a17ef5c4a2ea5c84a7 Mon Sep 17 00:00:00 2001
From: Nick Clifton <nickc@redhat.com>
Date: Tue, 11 Feb 2020 15:55:25 +0000
Subject: [PATCH] Import a fix from the mainline sources that prevents a
 potential illegal memory access when parsing PE binaries.

	PR 25447
	* coffgen.c (_bfd_coff_close_and_cleanup): Do not clear the keep
	syms and keep strings flags as these may have been set in order to
	prevent a bogus call to free.
---
 bfd/ChangeLog | 9 +++++++++
 bfd/coffgen.c | 6 ++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/bfd/coffgen.c b/bfd/coffgen.c
index 2bfcf1a6b14..3ddd2d89a83 100644
--- a/bfd/coffgen.c
+++ b/bfd/coffgen.c
@@ -3175,8 +3175,10 @@ _bfd_coff_close_and_cleanup (bfd *abfd)
       && bfd_family_coff (abfd)
       && coff_data (abfd) != NULL)
     {
-      obj_coff_keep_syms (abfd) = FALSE;
-      obj_coff_keep_strings (abfd) = FALSE;
+      /* PR 25447:
+	 Do not clear the keep_syms and keep_strings flags.
+	 These may have been set by pe_ILF_build_a_bfd() indicating
+	 that the syms and strings pointers are not to be freed.  */
       if (!_bfd_coff_free_symbols (abfd))
 	return FALSE;
     }
-- 
2.18.2