Skip to content

Commit

Permalink
Fix zap_ugni buffer race in accept path
Browse files Browse the repository at this point in the history
  • Loading branch information
narategithub authored and tom95858 committed Oct 9, 2023
1 parent 1970356 commit 022b4d2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/src/zap/ugni/zap_ugni.c
Original file line number Diff line number Diff line change
Expand Up @@ -1457,13 +1457,22 @@ static void process_uep_msg_connect(struct z_ugni_ep *uep)
CONN_LOG("%p sock-recv conn_msg: pe_addr: %#x, inst_id: %#x\n",
uep, msg->ep_desc.pe_addr, msg->ep_desc.inst_id);

void *data = NULL;
if (msg->data_len) {
data = malloc(msg->data_len);
if (!data)
return;
memcpy(data, msg->data, msg->data_len);
}

struct zap_event ev = {
.ep = &uep->ep,
.type = ZAP_EVENT_CONNECT_REQUEST,
.data_len = msg->data_len,
.data = (msg->data_len)?((void*)msg->data):(NULL)
.data = data
};
uep->ep.cb(&uep->ep, &ev);
free(data);

return;

Expand Down

0 comments on commit 022b4d2

Please sign in to comment.