Alejandro Pacheco 7a7336aa89 coap_dtls_receive(): Stop using the TLS data after coap_handle_dgram()
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.
2026-10-17 13:33:06 +01:00
2026-06-27 11:18:22 +01:00
2026-08-08 12:05:03 +01:00
2026-08-08 12:05:03 +01:00
2026-09-29 13:35:41 +01:00
2021-04-21 17:54:37 +02:00
2026-08-08 12:05:03 +01:00
2025-06-26 15:17:48 +01:00
2026-08-08 12:05:03 +01:00
2026-08-08 12:05:03 +01:00
2017-07-11 12:59:09 +02:00
2021-05-12 18:07:03 +01:00
2026-06-27 11:18:22 +01:00
2026-07-25 12:49:31 +01:00
2026-08-08 12:05:03 +01:00

libcoap: A C implementation of the Constrained Application Protocol (RFC 7252)

Build Status: develop Static Analysis Fuzzing Status CIFuzz Status pre-commit

Copyright (C) 2010—2026 by Olaf Bergmann bergmann@tzi.org and others

ABOUT LIBCOAP

libcoap is a C implementation of a lightweight application-protocol for devices that are constrained their resources such as computing power, RF range, memory, bandwidth, or network packet sizes. This protocol, CoAP, is standardized by the IETF as RFC 7252. For further information related to CoAP, see https://coap.space or CoAP Wiki.

You might want to check out libcoap-minimal for usage examples.

DOCUMENTATION

Documentation and further information can be found at https://libcoap.net.

PACKAGE CONTENTS

This package contains a protocol parser and basic networking functions for platforms with support for malloc() and BSD-style sockets. In addition, there is support for Contiki-NG, Espressif/ESP-IDF, LwIP and RIOT-OS hosted environments.

The following RFCs are supported

The following Internet Draft is supported

There is (D)TLS support for the following libraries

  • OpenSSL (Minimum version 1.1.0) [PKI, PSK and PKCS11]

  • GnuTLS (Minimum version 3.3.0) [PKI, PSK, RPK(3.6.6+) and PKCS11]

  • Mbed TLS (Minimum version 2.7.10) [PKI and PSK]

  • wolfSSL (Minimum version 5.2.0) [PKI, PSK, RPK(5.6.4+) and DTLS1.3(5.4.0+)]

  • TinyDTLS [PSK and RPK] [DTLS Only]

  • openHiTLS (Minimum version 0.4.0) [PKI and PSK]

The examples directory contain a CoAP client, CoAP Resource Directory server and a CoAP server to demonstrate the use of this library.

BUILDING

Further information can be found at https://libcoap.net/install.html and BUILDING.

LICENSE INFORMATION

This library is published as open-source software without any warranty of any kind. Use is permitted under the terms of the simplified BSD license. It includes public domain software. libcoap binaries may also include open-source software with their respective licensing terms. Please refer to LICENSE for further details.

Languages
C 93.8%
M4 2.9%
CMake 1.8%
Makefile 0.6%
Shell 0.5%
Other 0.4%