Projects
openEuler:C
gazelle
_service:tar_scm:0105-fix-func-separate_str_to_...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:0105-fix-func-separate_str_to_array-overflow-problem.patch of Package gazelle
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
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.