8 Star 0 Fork 26

src-anolis-os/binutils

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Always-allocate-a-new-pointer-for-section-name-that-.patch 1.79 KB
一键复制 编辑 原始数据 按行查看 历史
ticat_fp 提交于 2024-03-07 14:08 . LoongArch: fix some debug
From f800fc88f6576c65fb8e4a3cce1c8f060e912c98 Mon Sep 17 00:00:00 2001
From: ticat_fp <fanpeng@loongson.cn>
Date: Tue, 5 Mar 2024 14:56:22 +0800
Subject: [PATCH 1/2] Always allocate a new pointer for section name that may
be freed.
Signed-off-by: cailulu <cailulu@loongson.cn>
Signed-off-by: ticat_fp <fanpeng@loongson.cn>
---
bfd/peXXigen.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index 14100b8a..2102928e 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -170,25 +170,25 @@ _bfd_XXi_swap_sym_in (bfd * abfd, void * ext1, void * in1)
int unused_section_number = 0;
asection *sec;
flagword flags;
+ size_t name_len;
+ char *sec_name;
for (sec = abfd->sections; sec; sec = sec->next)
if (unused_section_number <= sec->target_index)
unused_section_number = sec->target_index + 1;
- if (name == namebuf)
+ name_len = strlen (name) + 1;
+ sec_name = bfd_alloc (abfd, name_len);
+ if (sec_name == NULL)
{
- name = (const char *) bfd_alloc (abfd, strlen (namebuf) + 1);
- if (name == NULL)
- {
- _bfd_error_handler (_("%B: out of memory creating name for empty section"),
- abfd);
- return;
- }
- strcpy ((char *) name, namebuf);
+ _bfd_error_handler (_("%pB: out of memory creating name "
+ "for empty section"), abfd);
+ return;
}
+ memcpy (sec_name, name, name_len);
flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_DATA | SEC_LOAD;
- sec = bfd_make_section_anyway_with_flags (abfd, name, flags);
+ sec = bfd_make_section_anyway_with_flags (abfd, sec_name, flags);
if (sec == NULL)
{
_bfd_error_handler (_("%B: unable to create fake empty section"),
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-anolis-os/binutils.git
git@gitee.com:src-anolis-os/binutils.git
src-anolis-os
binutils
binutils
a8

搜索帮助