net: sockets: tls: Check accepted context is not NULL
When closing a listening socket the functions waiting on the FIFO will be unblocked this will result in receiving a NULL child context. If that is the case return an error instead of carrying on. Return the same error code (EINVAL) that is returned on Linux when calling shutdown on a blocked accept call. Signed-off-by: Léonard Bise <leonard.bise@gmail.com>
This commit is contained in:
parent
5bb35892dd
commit
5cedb73555
1 changed files with 8 additions and 0 deletions
|
@ -1277,6 +1277,14 @@ int ztls_accept_ctx(struct net_context *parent, struct sockaddr *addr,
|
|||
}
|
||||
|
||||
child = k_fifo_get(&parent->accept_q, K_FOREVER);
|
||||
if (child == NULL) {
|
||||
z_free_fd(fd);
|
||||
/* Return EINVAL which is the same error code used under Linux
|
||||
* when calling shutdown on a blocked accept call
|
||||
*/
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (addr != NULL && addrlen != NULL) {
|
||||
int len = MIN(*addrlen, sizeof(child->remote));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue