5 Star 0 Fork 13

OpenCloudOS Stream/binutils

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Re-LoongArch-Add-support-for-b-.L1-and-beq-t0-t1-.L1.patch 1.58 KB
一键复制 编辑 原始数据 按行查看 历史
油屋 提交于 2024-11-07 15:00 . sync from upstream
From 311282d26b81bbe082f798e7b6100e8ef6f6d6ed Mon Sep 17 00:00:00 2001
From: Alan Modra <[email protected]>
Date: Sun, 24 Dec 2023 14:41:06 +1030
Subject: [PATCH 024/123] Re: LoongArch: Add support for <b ".L1"> and <beq,
$t0, $t1, ".L1">
This fixes the buffer overflow added in commit 22b78fad28, and a few
other problems.
* loongarch-coder.c (loongarch_split_args_by_comma): Don't
overflow buffer when args == "". Don't remove unbalanced
quotes. Don't trim last arg if max number of args exceeded.
---
opcodes/loongarch-coder.c | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/opcodes/loongarch-coder.c b/opcodes/loongarch-coder.c
index 672a468b..b6835276 100644
--- a/opcodes/loongarch-coder.c
+++ b/opcodes/loongarch-coder.c
@@ -255,22 +255,24 @@ loongarch_split_args_by_comma (char *args, const char *arg_strs[])
size_t num = 0;
if (*args)
- arg_strs[num++] = args;
- for (; *args; args++)
- if (*args == ',')
- {
- if (MAX_ARG_NUM_PLUS_2 - 1 == num)
- break;
- else
- *args = '\0', arg_strs[num++] = args + 1;
- }
-
- if (*(args-1) == '"')
{
- *(args-1) = '\0';
- arg_strs[num-1] = arg_strs[num-1] + 1;
- }
+ arg_strs[num++] = args;
+ for (; *args; args++)
+ if (*args == ',')
+ {
+ if (MAX_ARG_NUM_PLUS_2 - 1 == num)
+ goto out;
+ *args = '\0';
+ arg_strs[num++] = args + 1;
+ }
+ if (*(args - 1) == '"' && *arg_strs[num - 1] == '"')
+ {
+ *(args - 1) = '\0';
+ arg_strs[num - 1] += 1;
+ }
+ }
+ out:
arg_strs[num] = NULL;
return num;
}
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/opencloudos-stream/binutils.git
[email protected]:opencloudos-stream/binutils.git
opencloudos-stream
binutils
binutils
master

搜索帮助