Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipe reject use after free #2039

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/core/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1528,16 +1528,21 @@ nni_pipe_add(nni_pipe *p)

// nni_pipe_start attempts to start the pipe, adding it to the socket and
// endpoints and calling callbacks, etc. The pipe should already have finished
// any negotiation needed at the transport layer.
// any negotiation needed at the transport layer. Note carefully that the pipe
// may be destroyed before this function returns, as a result of work done by
// this function.
void
nni_pipe_start(nni_pipe *p)
{
// exactly one of these must be set.
NNI_ASSERT(p->p_listener == NULL || p->p_dialer == NULL);
NNI_ASSERT(p->p_listener != NULL || p->p_dialer != NULL);

// NB: starting the pipe can actually cause the pipe
// to be deallocated before this returns (if it is rejected)
if (p->p_listener) {
NNI_ASSERT(p->p_dialer == NULL);
listener_start_pipe(p->p_listener, p);
}
if (p->p_dialer) {
NNI_ASSERT(p->p_listener == NULL);
} else if (p->p_dialer) {
dialer_start_pipe(p->p_dialer, p);
}
}
Expand Down
Loading