Prevents the use of null pointers and sets the pointer to null after being used

This commit is contained in:
h30032433 2022-10-24 15:38:41 +08:00
parent 2f4d4958c3
commit 99db5cbd60
4 changed files with 105 additions and 1 deletions

View File

@ -0,0 +1,32 @@
From d86cf1b0d5ac6c0d900ae2b2a07fce7c4414d0e6 Mon Sep 17 00:00:00 2001
From: Alan Modra <amodra@gmail.com>
Date: Sat, 7 Aug 2021 14:10:38 +0930
Subject: [PATCH] PR28186, SEGV elf.c:7991:30 in _bfd_elf_fixup_group_sections
PR 28186
* elf.c (_bfd_elf_fixup_group_sections): Don't segfault on
objcopy/strip with NULL output_section.
(cherry picked from commit 182ad37589e3931390d0c43f1d52a9a6e0062a61)
Reference:https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=d86cf1b0d5ac6c0d900ae2b2a07fce7c4414d0e6
Conflict:NA
---
bfd/elf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bfd/elf.c b/bfd/elf.c
index de5abafabf0..9c3f34c415b 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -7984,7 +7984,7 @@ _bfd_elf_fixup_group_sections (bfd *ibfd, asection *discarded)
isec->flags |= SEC_EXCLUDE;
}
}
- else
+ else if (isec->output_section != NULL)
{
/* Adjust the output section size when called from
objcopy. */
--
2.23.0

View File

@ -0,0 +1,33 @@
From c20c7adbeaa3af18a58ba1e20e6c33e7186356e3 Mon Sep 17 00:00:00 2001
From: Alan Modra <amodra@gmail.com>
Date: Wed, 6 Oct 2021 18:28:47 +1030
Subject: [PATCH] PR28422, build_id use-after-free
This fixes a bug in commit 5d9bbb73c1df. All fields preserved from a
bfd in struct bfd_preserve need to be cleared in bfd_reinit.
PR 28422
* format.c (bfd_reinit): Clear build_id.
(cherry picked from commit 6d661cdc5be46e890ed9255e749806f46a88e26c)
Reference:https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=c20c7adbeaa3af18a58ba1e20e6c33e7186356e3
Conflict:NA
---
bfd/format.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/bfd/format.c b/bfd/format.c
index 5d08d1d642c..408c984690e 100644
--- a/bfd/format.c
+++ b/bfd/format.c
@@ -151,6 +151,7 @@ bfd_reinit (bfd *abfd, unsigned int section_id, bfd_cleanup cleanup)
abfd->tdata.any = NULL;
abfd->arch_info = &bfd_default_arch_struct;
abfd->flags &= BFD_FLAGS_SAVED;
+ abfd->build_id = NULL;
bfd_section_list_clear (abfd);
}
--
2.23.0

View File

@ -0,0 +1,32 @@
From 96eb21265ebffbc28f767bed9a2b7650ecb9818d Mon Sep 17 00:00:00 2001
From: Alan Modra <amodra@gmail.com>
Date: Thu, 4 Nov 2021 14:11:02 +1030
Subject: [PATCH] PR28540, segmentation fault on NULL byte_get
PR 28540
* objdump.c (dump_bfd): Don't attempt load_separate_debug_files
when byte_get is NULL.
(cherry picked from commit f2f105f518413ea3e4c212f89585f9a8a5dddcdd)
Reference:https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=96eb21265ebffbc28f767bed9a2b7650ecb9818d
Conflict:NA
---
binutils/objdump.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/binutils/objdump.c b/binutils/objdump.c
index a7b8303b992..50317b3d48f 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -4869,7 +4869,7 @@ dump_bfd (bfd *abfd, bool is_mainfile)
The test on is_mainfile is there because the chain of separate debug
info files is a global variable shared by all invocations of dump_bfd. */
- if (is_mainfile)
+ if (byte_get != NULL && is_mainfile)
{
load_separate_debug_files (abfd, bfd_get_filename (abfd));
--
2.23.0

View File

@ -1,7 +1,7 @@
Summary: Binary utilities Summary: Binary utilities
Name: binutils Name: binutils
Version: 2.37 Version: 2.37
Release: 13 Release: 14
License: GPLv3+ License: GPLv3+
URL: https://sourceware.org/binutils URL: https://sourceware.org/binutils
@ -69,6 +69,10 @@ Patch43: backport-0001-texi2pod.pl-add-no-op-no-split-option-support-PR2814.patc
Patch44: backport-AArch64-Add-support-for-AArch64-EFI-efi-aarch64.patch Patch44: backport-AArch64-Add-support-for-AArch64-EFI-efi-aarch64.patch
Patch45: backport-Add-support-for-AArch64-EFI-efi-aarch64.patch Patch45: backport-Add-support-for-AArch64-EFI-efi-aarch64.patch
Patch46: backport-don-t-over-align-file-positions-of-PE-executable-sec.patch Patch46: backport-don-t-over-align-file-positions-of-PE-executable-sec.patch
Patch47: backport-PR28186-SEGV-elf.c-7991-30-in-_bfd_elf_fixup_group_sections.patch
Patch48: backport-PR28422-build_id-use-after-free.patch
Patch49: backport-PR28540-segmentation-fault-on-NULL-byte_get.patch
Provides: bundled(libiberty) Provides: bundled(libiberty)
@ -392,6 +396,9 @@ fi
%{_infodir}/bfd*info* %{_infodir}/bfd*info*
%changelog %changelog
* Mon Oct 24 2022 huyubiao <huyubiao@huawei.com> - 2.37-14
- DESC:Prevents the use of null pointers and sets the pointer to null after being used.
* Tue Oct 18 2022 konglidong <konglidong@uniontech.com> - 2.37-13 * Tue Oct 18 2022 konglidong <konglidong@uniontech.com> - 2.37-13
- DESC:fix the changelog exception macro - DESC:fix the changelog exception macro