diff options
author | 2019-03-01 16:46:11 +0000 | |
---|---|---|
committer | 2019-03-01 16:46:11 +0000 | |
commit | 5a9013c5cbe8ffb15a4268249317603de631fd47 (patch) | |
tree | f1b6cdeeb17a64487fc5b75abad338c7c0edbec5 | |
parent | de-obfuscate by expanding three useless macros; no functional change; (diff) | |
download | wireguard-openbsd-5a9013c5cbe8ffb15a4268249317603de631fd47.tar.xz wireguard-openbsd-5a9013c5cbe8ffb15a4268249317603de631fd47.zip |
Fix a crash: don't assume that all input files are ELF objects
ld(1) would try to free uninitialized memory when used with -r -b binary
<fontfile> by ports/textproc/mupdf. Perform the same bfd type check
as bfd_elf_match_symbols_in_sections(). Fix found the hard way,
cheese and wine sponsor: miod. Almost identical fix already present
upstream.
Also set the freed pointer to NULL, just in case.
ok tb@ sthen@
-rw-r--r-- | gnu/usr.bin/binutils-2.17/bfd/elflink.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gnu/usr.bin/binutils-2.17/bfd/elflink.c b/gnu/usr.bin/binutils-2.17/bfd/elflink.c index f1a67caeeaa..d6fe664949f 100644 --- a/gnu/usr.bin/binutils-2.17/bfd/elflink.c +++ b/gnu/usr.bin/binutils-2.17/bfd/elflink.c @@ -8619,8 +8619,13 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) if (!info->reduce_memory_overheads) { for (sub = info->input_bfds; sub != NULL; sub = sub->link_next) - if (elf_tdata (sub)->symbuf) - free (elf_tdata (sub)->symbuf); + { + if (bfd_get_flavour (sub) == bfd_target_elf_flavour) + { + free (elf_tdata (sub)->symbuf); + elf_tdata (sub)->symbuf = NULL; + } + } } /* Output any global symbols that got converted to local in a |