Host names larger than 255 bytes will cause an internal buffer overflow.
Hostnames provided to coap_resolve_address_info() now have their length validated.
Discovered by SecMate (https://secmate.dev).
Sanity check host lengths when parsing a CoAP URI when using the coap_split_uri()
function.
With a large boolean parameter value, (longer than "false"), memory
would be read past the "true" or "false" string boundaries in the ".rodata"
section when doing a memcmp(), potetially causing the application to crash
when calling coap_new_oscore_conf() with a specially crafted configuration
file.
It also can provide a mechanism to determine the byte values following the
"true" or "false" string boundaries which could lead to accessing sensitive
information. The standard libcoap library does not have defined keys or
certificates. This can only be done by a specially crafted local application.
Discovered by SecMate (https://secmate.dev).
Now fixed.
Some of the Zephyr include files need to be C++, not C based. The 'extern "C"'
wrapper in include/coap3/coap.h means that all #include are treated as being C.
Remove 'extern "C"' wrapper from include/coap3/coap.h and add wrapper to
include files after #include and before any function / structure definitions.
Add in a C++ build test for CI.
- Add wolfSSL detection and configuration in zephyr/CMakeLists.txt
- Set wolfSSL to take priority over mbedTLS when both are available
- Bypass find_package() call and link wolfSSL library directly
- Prevent system wolfSSL library conflicts with ZEPHYR_BASE checks
- Fix compiler warnings in coap_wolfssl.c for unused functions
Let libcoap do the necessary multi-thread locking during resource
generation, lookup and deletion.
Supported using a new handler set up by coap_register_dynamic_resource_handler().
Server to Client is already supported, this provides the reverse with
coap_session_set_type_server().
Add in call-home support to coap-client and coap-server for testing.
Addition of a new event COAP_EVENT_SERVER_SESSION_CONNECTED.
Changes:
- Remove duplicate OBSERVE_PERSIST configuration block
Improve example build:
- Make virtual environment activation optional in Makefile
- Remove --fresh flag unsupported in newer west versions
- Copy mbedTLS config header to workspace include directory
- Add TARGET check for mbedTLS before configuring include directories
- Add mbedTLS linking to coap-3 target
Add POSIX API support:
- Enable CONFIG_POSIX_API=y in examples/zephyr
- Replace direct Linux/Windows system calls with Zephyr POSIX API
equivalents
- Add Zephyr's sys_rand_get() to coap_prng_default()
- Define missing network macros (IN_MULTICAST, IN6_IS_ADDR_MULTICAST,
etc.)
- Add FIONBIO and OPTVAL_T/OPTVAL_GT macro definitions for Zephyr
- Add native Zephyr timing functions to replace missing mbedTLS timing
support
- Fix fd_set mapping using zephyr/net/socket_select.h
- Exclude strnlen redefinition conflicts for Zephyr
- Add proper IPv6 packet info and address mapped definitions
(Patch) Add DNS resolution and net setup to example client:
- Enable CONFIG_DNS_RESOLVER for hostname resolution
- Add Linux networking setup instructions for native_sim board
- Configure static IP gateway and DNS server (8.8.8.8)
- Add DHCP vs static IP configuration documentation
Co-authored-by: mrdeep1
Move the MinGW #if tests to after where mswsock.h is included.
Tidy up documentation.
Tested against MSYS2 UCRT64, CLANG64, MINGW32 and MINGW64 on Windows 11.
Fixed a couple of minor build issues found.
Multiple threads can call coap_check_async() when one of them does a callback
into application space. Only allow one thread to be scanning async_state.
MbedTLS based PKI clients may report
SSL - Attempt to verify a certificate without an expected hostname.
This is usually insecure. In TLS clients, when a client authenticates a
server through its certificate, the client normally checks three things: ....
The application provided client_sni may have been removed as per
https://datatracker.ietf.org/doc/html/rfc6066#section-3
Literal IPv4 and IPv6 addresses are not permitted in "HostName".
and so MbedTLS is now explicitly told that therw is no hostname.
In particular for TCP support.
Also added in retrying to get the lwip git 3 times for the CI tests as the
lwip host server is currently not that reliable, returning 502 gateway errors.
Makes reading the code simpler.
Context is no longer used as global_lock is used in the coap_lock_lock() and
coap_lock_unlock() functions.
Part 3 of 3.
Update coap_lock_lock() and coap_lock_unlock() macros and all users.
Makes reading the code simpler.
Context is no longer used as global_lock is used in the coap_lock_lock() and
coap_lock_unlock() functions.
Part 2 of 3.
Update coap_lock_check_locked() and all users.
Makes reading the code simpler.
Context is no longer used as global_lock is used in the coap_lock_lock() and
coap_lock_unlock() functions.
Part 1 of 3.
Update coap_lock_callback(), coap_lock_callback_ret(),
coap_lock_callback_release(), coap_lock_callback_ret_release() and
coap_lock_invert() macros and all users.
If multiple clients subscribe to the same resource, one of the clients
'goes away', the server will eventually close down the session for that client
which will then remove any subscriptions, iterating through the different
resources.
If this happens at the same time that coap_resource_notify_observers() is called
in another thread, and the GET/FETCH handler is called for a common resource
and in particular for the session that is now going away, on return from the
callback the subscription may no longer exist. This PR fixes this window.
In addition, if the resource subscriber list is being traversed, then a another
call to coap_notify_observers() for the same resource will not generate a new set
unsolicited observe responses for multi-thread protection.
Update
Malformed PDUs were responsed to with a RST. Now request PDUs with invalid
lengths are also reported with a 4.02 response.
See RFC7252 5.4.3 and 5.4.1.