Add reference counting to recipient contexts so they can be safely removed
while still in use by active sessions. Expose callback hooks for credential
lookup, echo, and sequence storage to allow custom backends.
Expand example server to demonstrate the external storage via a simple
file based database. Expand coap_oscore_rcp_conf_t to enable settings
preconfigured echo value, sequence counter and window value as uint64
Enable temporary credentials returned by the find function and are destroyed
after use.
Check incoming Uri-Path and Location-Path options for just . or .. (or %2e
hex encoded variants) and treat as being invalid.
Stop insertion of Uri-Path and Location-Path options that contain just
. or .. (or %2e hex encoded variants).
When a Uri-Query filter ends in '=' with no value bytes (e.g. "rt="),
the filter parser computes resource_param.length == query_filter->length - 1
and query_pattern.length == 0, but then unconditionally dereferences
query_pattern.s[0] to test for a leading '/'. With the current allocator
strategy in coap_new_string() (which over-allocates by 1 byte for a NUL
terminator) this read lands on the NUL slot and is harmless; ASan does
not flag it on the dispatch path.
However, coap_print_wellknown is a public, exported COAP_API. A caller
passing a tightly-allocated coap_string_t (length == alloc_size, no
trailing slack) hits a 1-byte heap-buffer-overflow read at
src/coap_resource.c:178. The man page does not document any required
allocation slack, so this is an API-contract footgun rather than only an
internal invariant violation.
Mirror the existing guard already in place for the trailing '*' check
(line 183) by guarding the leading '/' check on query_pattern.length > 0.
Reproducer (clang + ASan, against HEAD e3f8cd0):
uint8_t *filter = malloc(3);
memcpy(filter, "rt=", 3);
coap_string_t qf = { .length = 3, .s = filter };
coap_print_wellknown(ctx, out, &out_buflen, 0, &qf);
/* AddressSanitizer: heap-buffer-overflow READ of size 1
* #0 coap_print_wellknown_lkd src/coap_resource.c:178
* #1 coap_print_wellknown src/coap_resource.c:110 */
After the fix the PoC exits cleanly; the sanity case "rt=x" (length>0)
continues to work unchanged.
Signed-off-by: OwenSanzas <zesheng@tamu.edu>
- fix(cmake): only create alias if it doesn't exist:
Zephyr v4.4 has moved to MbedTLS 4.x in following PR:
https://github.com/zephyrproject-rtos/zephyr/pull/104031
Zephyr now uses MbedTLS' CMakeLists, which exports targets
with NAMESPACE MbedTLS::, therefore MbedTLS::mbedtls,
MbedTLS::mbedx509, MbedTLS::tfpsacrypto aliases already exist
- fix(zephyr): v4.4: include correct mbedtls config based on zephyr version
CONFIG_MBEDTLS_CFG_FILE was deprecated. Instead, CONFIG_MBEDTLS_CONFIG_FILE
shall be used. This change supports both based on Kconfig symbols.
Signed-off-by: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com>