1 Star 0 Fork 32

shafeipaozi/gazelle

forked from src-openEuler/gazelle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0105-fix-func-separate_str_to_array-overflow-problem.patch 2.52 KB
一键复制 编辑 原始数据 按行查看 历史
From c6de43f7e7cb866f8d5ddd453c73783d5daafca0 Mon Sep 17 00:00:00 2001
From: yinbin <yinbin8@huawei.com>
Date: Wed, 27 Dec 2023 12:22:06 +0800
Subject: [PATCH] fix func separate_str_to_array overflow problem
---
src/lstack/core/lstack_protocol_stack.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c
index b5d4ea3..f3d2452 100644
--- a/src/lstack/core/lstack_protocol_stack.c
+++ b/src/lstack/core/lstack_protocol_stack.c
@@ -651,44 +651,57 @@ int32_t stack_setup_thread(void)
struct thread_params *t_params[PROTOCOL_STACK_MAX] = {NULL};
int process_index = get_global_cfg_params()->process_idx;
+ for (uint32_t i = 0; i < queue_num; ++i) {
+ t_params[i] = malloc(sizeof(struct thread_params));
+ if (t_params[i] == NULL) {
+ goto OUT;
+ }
+ }
+
for (uint32_t i = 0; i < queue_num; i++) {
if (get_global_cfg_params()->seperate_send_recv) {
if (i % 2 == 0) {
ret = sprintf_s(name, sizeof(name), "%s_%d_%d", LSTACK_RECV_THREAD_NAME, process_index, i / 2);
if (ret < 0) {
- return -1;
+ goto OUT;
}
} else {
ret = sprintf_s(name, sizeof(name), "%s_%d_%d", LSTACK_SEND_THREAD_NAME, process_index, i / 2);
if (ret < 0) {
- return -1;
+ goto OUT;
}
}
} else {
ret = sprintf_s(name, sizeof(name), "%s", LSTACK_THREAD_NAME);
if (ret < 0) {
- return -1;
+ goto OUT;
}
}
- t_params[i] = malloc(sizeof(struct thread_params));
t_params[i]->idx = i;
t_params[i]->queue_id = process_index * queue_num + i;
ret = create_thread((void *)t_params[i], name, gazelle_stack_thread);
if (ret != 0) {
- return ret;
+ goto OUT;
}
}
/* 2: wait stack thread and kernel_event thread init finish */
wait_sem_value(&g_stack_group.sem_stack_setup, queue_num * 2);
if (g_stack_group.stack_setup_fail) {
- return -1;
+ goto OUT;
}
g_stack_group.stack_num = queue_num;
return 0;
+OUT:
+ for (int32_t i = 0; i < queue_num; ++i) {
+ if (t_params[i] != NULL) {
+ free(t_params[i]);
+ }
+ }
+ return -1;
}
void stack_arp(struct rpc_msg *msg)
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/shafeipaozi/gazelle.git
git@gitee.com:shafeipaozi/gazelle.git
shafeipaozi
gazelle
gazelle
master

搜索帮助