Fixed TURN session use after free #3814
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To fix #3776.
In
turn_session.c
stun_on_request_complete(pj_stun_session *stun, ..., void *token, ...)
, we will access the token passed in the parameter, but in this case, the token has become invalid since the pool has been released inturn_sock.c
dataconn_on_data_read()
.The issue seems to be caused because the token used (
conn_bind
) is allocated from the dataconn's pool.dataconn_on_connect_complete()
->pj_turn_session_connection_bind(turn_sock->sess, conn->pool, ...)
: