For a request set up with coap_add_data_large_request_app(), the data
is provided by the application's get_func and there is no data pointer.
Three places still took the body from that NULL pointer, so
coap_add_data() was passed a NULL pointer:
- check_freshness(), re-sending the next block with the Echo option
from a 4.01 response.
- coap_cancel_observe_lkd(), re-adding the observe request's body to
the cancel request.
- coap_add_data_large_internal(), when the application sets a Block1
option with a non-zero block number to send a single block.
Use get_func in all of these, as the other places that send a block of
an lg_xmit already do. The single block and the whole-body cases now
share add_get_func_data(), which also checks the allocation and no
longer leaks the buffer when get_func fails.
Add unit tests.
With track_client_session set, an incoming session gets its own proxy
entry for each upstream server it uses. coap_proxy_remove_association()
returned after the first entry tracking the session, so the proxy
requests of that session held in later entries were left in place when
the session was deleted, and their upstream sessions were not released.
A later upstream response was then forwarded to the freed session.
Carry on with the remaining entries instead of returning.
Add a unit test.
Packets from the same peer can overwrite a session's local address with a
multicast destination. Save the address when an observation is created or
renewed and restore it before generating notifications, so deferred responses
snapshot the correct address instead of being dropped as invalid multicast.
Add regression coverage for CON and NON observations, including renewals and
the local address captured by a notification's async response.
Validation: 215 unit tests passed (1712 assertions).
Support matching multiple, space separated, values, not limited to if=, rt= and rel=.
Fix OOB read if the last space separated value is shorter than the query.
Support matching against multiple queries.
Do not sent back empty 2.05 response if multicast.
CBOR array and map counts can exceed UINT16_MAX. The uint16_t loop counters
then wrap and never reach the advertised count, causing a CWE-835 denial of
service.
Use size_t loop counters and reject counts that cannot fit in the remaining
buffer at the minimum encoding size of one byte per array element or two
bytes per map pair. Propagate malformed-value errors and cover large
malformed containers and valid values over 64 KiB with regression tests.
New ./configure option
--with-mbedtls-oscore
If --disable-dtls is set, then MbedTLS is used as the OSCORE backend, otherwise
the MbedTLS library is used for both (D)TLS and OSCORE.
New cmake option
-DOSCORE_BACKEND=mbedtls
If -DENABLE_DTLS=OFF is set, then MbedTLS is used as the OSCORE backend, otherwise
the MbedTLS library is used for both (D)TLS and OSCORE.
New Zephyr option
config MBEDTLS_OSCORE
If set to y and CONFIG_LIBCOAP_OSCORE_SUPPORT is set to y, then the Zephyr MbedTLS
backend will get used for the OSCORE backend (no (D)TLS).
The goal is to extend code coverage of libcoap. Can confirm from local
runs this provides a significant boost to coap_cache.c coverage.
Signed-off-by: David Korczynski <david@adalogics.com>
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).
Analyzer run time does not like A -= B or A +=B even if A and B are uint32_t as there is potential
for overflow.
Analyzer run time does not like overflow when doing coap_tick_t - coap_tick_t.
Analyzer run time does not like (uint8_t << 24) as uint8_t is promoted as int, not u_int.
Analyzer run time does not like while(A--) {} even if A is uint32_t, as A is always decremented on
the test, even if the value of A is 0.
Fix potential overflow when analyzing an asn.1 tag.
Fix potential overflow when doing decode_segment() on a % hex value.