net: tcp: Verify accept callback before use
Closing a listening socket will set the accept callback to NULL. This could lead to a crash, in case an already received packet, finalizing the connection handshake, was processed after the socket was closed. Thereby, it's needed to verify if the callback is actually set before processing it. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
parent
08752aed0f
commit
81b92fcbb3
1 changed files with 7 additions and 5 deletions
|
@ -1825,11 +1825,13 @@ next_state:
|
|||
NET_CONTEXT_CONNECTED);
|
||||
|
||||
if (conn->accepted_conn) {
|
||||
conn->accepted_conn->accept_cb(
|
||||
conn->context,
|
||||
&conn->accepted_conn->context->remote,
|
||||
sizeof(struct sockaddr), 0,
|
||||
conn->accepted_conn->context);
|
||||
if (conn->accepted_conn->accept_cb) {
|
||||
conn->accepted_conn->accept_cb(
|
||||
conn->context,
|
||||
&conn->accepted_conn->context->remote,
|
||||
sizeof(struct sockaddr), 0,
|
||||
conn->accepted_conn->context);
|
||||
}
|
||||
|
||||
/* Make sure the accept_cb is only called once.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue