mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 01:05:54 +08:00
TCP Networking: When CONFIG_NET_TCP_WRITE_BUFF=y there is a situation where a NULL pointer may be dereferenced. In this configuration, the TCP connection's 'semi-permnanent' callback, s_sndcb was nullified in tcp_close_disconnect. However, other logic in tcp_lost_connection() attempt to use that callback reference after it was nullifed. Fixed in tcp_lost_connectino() by adding a NULL pointer change before the access. This was reported by Dmitriy Linikov in Bitbucket Issue 72.
This commit is contained in:
@@ -339,21 +339,18 @@ static inline int tcp_close_disconnect(FAR struct socket *psock)
|
||||
/* Interrupts are disabled here to avoid race conditions */
|
||||
|
||||
net_lock();
|
||||
conn = (FAR struct tcp_conn_s *)psock->s_conn;
|
||||
|
||||
conn = (FAR struct tcp_conn_s *)psock->s_conn;
|
||||
DEBUGASSERT(conn != NULL);
|
||||
|
||||
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
|
||||
/* If we have a semi-permanent write buffer callback in place, then
|
||||
* release it now.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
|
||||
if (psock->s_sndcb)
|
||||
{
|
||||
psock->s_sndcb = NULL;
|
||||
}
|
||||
psock->s_sndcb = NULL;
|
||||
#endif
|
||||
|
||||
DEBUGASSERT(conn != NULL);
|
||||
|
||||
/* Check for the case where the host beat us and disconnected first */
|
||||
|
||||
if (conn->tcpstateflags == TCP_ESTABLISHED &&
|
||||
|
||||
Reference in New Issue
Block a user