fix CVE-2022-47008
(cherry picked from commit ed246ee990c1e8c9fbf453e8909ca4d90f058359)
This commit is contained in:
parent
37d7387dfc
commit
6b44e54bca
61
CVE-2022-47008.patch
Normal file
61
CVE-2022-47008.patch
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
From d6e1d48c83b165c129cb0aa78905f7ca80a1f682 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Alan Modra <amodra@gmail.com>
|
||||||
|
Date: Fri, 17 Jun 2022 09:13:38 +0930
|
||||||
|
Subject: [PATCH] PR29255, memory leak in make_tempdir
|
||||||
|
|
||||||
|
PR 29255
|
||||||
|
* bucomm.c (make_tempdir, make_tempname): Free template on all
|
||||||
|
failure paths.
|
||||||
|
---
|
||||||
|
binutils/bucomm.c | 20 +++++++++++---------
|
||||||
|
1 file changed, 11 insertions(+), 9 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/binutils/bucomm.c b/binutils/bucomm.c
|
||||||
|
index fdc2209df9c..4395cb9f7f5 100644
|
||||||
|
--- a/binutils/bucomm.c
|
||||||
|
+++ b/binutils/bucomm.c
|
||||||
|
@@ -537,8 +537,9 @@ make_tempname (const char *filename, int *ofd)
|
||||||
|
#else
|
||||||
|
tmpname = mktemp (tmpname);
|
||||||
|
if (tmpname == NULL)
|
||||||
|
- return NULL;
|
||||||
|
- fd = open (tmpname, O_RDWR | O_CREAT | O_EXCL, 0600);
|
||||||
|
+ fd = -1;
|
||||||
|
+ else
|
||||||
|
+ fd = open (tmpname, O_RDWR | O_CREAT | O_EXCL, 0600);
|
||||||
|
#endif
|
||||||
|
if (fd == -1)
|
||||||
|
{
|
||||||
|
@@ -556,22 +557,23 @@ char *
|
||||||
|
make_tempdir (const char *filename)
|
||||||
|
{
|
||||||
|
char *tmpname = template_in_dir (filename);
|
||||||
|
+ char *ret;
|
||||||
|
|
||||||
|
#ifdef HAVE_MKDTEMP
|
||||||
|
- return mkdtemp (tmpname);
|
||||||
|
+ ret = mkdtemp (tmpname);
|
||||||
|
#else
|
||||||
|
- tmpname = mktemp (tmpname);
|
||||||
|
- if (tmpname == NULL)
|
||||||
|
- return NULL;
|
||||||
|
+ ret = mktemp (tmpname);
|
||||||
|
#if defined (_WIN32) && !defined (__CYGWIN32__)
|
||||||
|
if (mkdir (tmpname) != 0)
|
||||||
|
- return NULL;
|
||||||
|
+ ret = NULL;
|
||||||
|
#else
|
||||||
|
if (mkdir (tmpname, 0700) != 0)
|
||||||
|
- return NULL;
|
||||||
|
+ ret = NULL;
|
||||||
|
#endif
|
||||||
|
- return tmpname;
|
||||||
|
#endif
|
||||||
|
+ if (ret == NULL)
|
||||||
|
+ free (tmpname);
|
||||||
|
+ return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Parse a string into a VMA, with a fatal error if it can't be
|
||||||
|
--
|
||||||
|
2.39.3
|
||||||
@ -1,7 +1,7 @@
|
|||||||
Summary: Binary utilities
|
Summary: Binary utilities
|
||||||
Name: binutils
|
Name: binutils
|
||||||
Version: 2.37
|
Version: 2.37
|
||||||
Release: 15
|
Release: 16
|
||||||
License: GPLv3+
|
License: GPLv3+
|
||||||
URL: https://sourceware.org/binutils
|
URL: https://sourceware.org/binutils
|
||||||
|
|
||||||
@ -73,6 +73,7 @@ Patch47: backport-PR28186-SEGV-elf.c-7991-30-in-_bfd_elf_fixup_group_sections.pa
|
|||||||
Patch48: backport-PR28422-build_id-use-after-free.patch
|
Patch48: backport-PR28422-build_id-use-after-free.patch
|
||||||
Patch49: backport-PR28540-segmentation-fault-on-NULL-byte_get.patch
|
Patch49: backport-PR28540-segmentation-fault-on-NULL-byte_get.patch
|
||||||
Patch50: Fix-gold-relocation-offset-and-adrp-signed-shife.patch
|
Patch50: Fix-gold-relocation-offset-and-adrp-signed-shife.patch
|
||||||
|
Patch51: CVE-2022-47008.patch
|
||||||
|
|
||||||
Provides: bundled(libiberty)
|
Provides: bundled(libiberty)
|
||||||
|
|
||||||
@ -396,6 +397,9 @@ fi
|
|||||||
%{_infodir}/bfd*info*
|
%{_infodir}/bfd*info*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Aug 23 2023 liningjie <liningjie@xfusion.com> - 2.37-16
|
||||||
|
- fix CVE-2022-47008
|
||||||
|
|
||||||
* Thu Apr 20 2023 dingguangya <dingguangya1@huawei.com> - 2.37-15
|
* Thu Apr 20 2023 dingguangya <dingguangya1@huawei.com> - 2.37-15
|
||||||
- Type:bugfix
|
- Type:bugfix
|
||||||
- ID:NA
|
- ID:NA
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user