Properly handle a closed TLS socket with pending receive data.
If the remote end closes a TLS socket and the socket buffer still contains not-yet-decrypted TLS records but no decrypted TLS records, soreceive needs to block or fail with EWOULDBLOCK. Previously it was trying to return data and dereferencing a NULL pointer. Reviewed by: np Sponsored by: Chelsio Differential Revision: https://reviews.freebsd.org/D25838
This commit is contained in:
parent
adeebf4cd4
commit
0f70a1489d
@ -1965,12 +1965,17 @@ soreceive_generic(struct socket *so, struct sockaddr **psa, struct uio *uio,
|
||||
}
|
||||
SOCKBUF_LOCK_ASSERT(&so->so_rcv);
|
||||
if (so->so_rcv.sb_state & SBS_CANTRCVMORE) {
|
||||
if (m == NULL && so->so_rcv.sb_tlsdcc == 0 &&
|
||||
if (m != NULL)
|
||||
goto dontblock;
|
||||
#ifdef KERN_TLS
|
||||
else if (so->so_rcv.sb_tlsdcc == 0 &&
|
||||
so->so_rcv.sb_tlscc == 0) {
|
||||
#else
|
||||
else {
|
||||
#endif
|
||||
SOCKBUF_UNLOCK(&so->so_rcv);
|
||||
goto release;
|
||||
} else
|
||||
goto dontblock;
|
||||
}
|
||||
}
|
||||
for (; m != NULL; m = m->m_next)
|
||||
if (m->m_type == MT_OOBDATA || (m->m_flags & M_EOR)) {
|
||||
|
Loading…
Reference in New Issue
Block a user