mirror of
https://github.com/obgm/libcoap.git
synced 2026-10-27 13:11:24 +03:00
Handling a received PDU can disconnect the session, for example when the response cannot be sent and coap_send_internal() calls coap_session_disconnected_lkd(), which closes session->tls and frees it. After coap_handle_dgram() returned, coap_dtls_receive() in the wolfSSL backend still cleared the pdu pointer in the freed TLS data, and the OpenSSL backend read it through the already freed BIO. Clear the pdu pointer before passing the decrypted data to coap_handle_dgram() and return its result directly, as the GnuTLS backend already does, so the TLS data is never touched once the PDU has been handed on. Do the same before the DTLS connected event and l_establish() on handshake completion. Mbed TLS checked session->tls for NULL instead; give it the same structure. Add a unit test where the server's response write fails.