heap use after free in xcoff_archive_info_eq
Alan Modra
amodra@gmail.com
Thu Sep 3 01:37:01 GMT 2020
Using an input file objalloc memory for anything that isn't created
when opening the bfd is not a good idea. The problem is that this
memory can disappear if bfd_free_cached_info is called or when bfd
closes files in order to keep the number of open files reasonable.
bfd/
* xcofflink.c (xcoff_get_archive_info): Allocate xcoff_archive_info
on the output bfd objalloc memory.
ld/
* testsuite/ld-scripts/sysroot-prefix.exp (single_sysroot_prefix_test):
Log $scriptname.
diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c
index 8870525472..ca7d7fec04 100644
--- a/bfd/xcofflink.c
+++ b/bfd/xcofflink.c
@@ -525,7 +525,7 @@ xcoff_get_archive_info (struct bfd_link_info *info, bfd *archive)
entryp = *slot;
if (!entryp)
{
- entryp = bfd_zalloc (archive, sizeof (entry));
+ entryp = bfd_zalloc (info->output_bfd, sizeof (entry));
if (!entryp)
return NULL;
diff --git a/ld/testsuite/ld-scripts/sysroot-prefix.exp b/ld/testsuite/ld-scripts/sysroot-prefix.exp
index e8b45d18e1..b7590e25a6 100644
--- a/ld/testsuite/ld-scripts/sysroot-prefix.exp
+++ b/ld/testsuite/ld-scripts/sysroot-prefix.exp
@@ -164,7 +164,7 @@ proc single_sysroot_prefix_test { type xtestname finalscript ldopt errstr } {
puts $ofd "$finalscript"
close $ofd
- verbose -log "script: $finalscript"
+ verbose -log "script $scriptname: $finalscript"
set res [ld_link $ld tmpdir/output "$ldopt tmpdir/main.o -Ltmpdir -lsysroottest"]
set ld_output "$exec_output"
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list