Commit Graph
166 Commits
Author SHA1 Message Date
Arthur Chan 60dad69e95 OSS-Fuzz: Fix observe fuzzer
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-05-08 09:31:43 +01:00
Arthur Chan 76a793be5c OSS-Fuzz: Add a helper for fuzzing
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-05-07 19:36:44 +01:00
Arthur Chan feab110c7f OSS-Fuzz: Fix block_check_fuzzer
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-05-07 14:22:46 +01:00
Ernestas Kulik 766b852849 Implement support for LLC sockets
Useful in embedded contexts, where devices might only have a link-layer
connection, but still need to exchange information.
2026-04-18 09:11:19 +01:00
Arthur Chan caa7120cae OSS-Fuzz: Add fuzzer for block low level checking
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-03-28 10:44:50 +00:00
Arthur Chan f283c7b69b OSS-Fuzz: Fix block fuzzer
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-03-28 10:44:31 +00:00
Jon Shallow 80c37b7bc6 Coverity: Fix CID 1483550, 1670422-1670425
CID 1594475 is a false positive as multiple threads cannot execute in the same
code as global_lock is set.
2026-03-26 09:24:44 +00:00
Arthur Chan efec6cf653 OSS-Fuzz: Fix packet transmission checking for network related fuzzers
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-03-20 21:26:34 +00:00
Arthur Chan 407e6b06cf OSS-Fuzz: Add fuzzer targeting coap_async
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-03-20 16:09:12 +00:00
Florek, Bartlomiej 44e5c68c51 fix: OSCORE ACK retransmission handling 2026-03-19 15:13:32 +00:00
Arthur Chan 766711f62c OSS-Fuzz: Revamp block_fuzzer and add corpus seed
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-03-18 10:05:42 +00:00
Arthur Chan f39d2152b3 OSS-Fuzz: Add observe fuzzer
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-03-16 12:40:27 +00:00
Arthur Chan cc8de29bd4 OSS-Fuzz: Add more targets to network fuzzer
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-03-13 13:53:45 +00:00
Jon Shallow 40502ffebb oss-fuzz: Fix undefined-behavior
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.
2026-03-10 11:09:10 +00:00
Jon Shallow fe41b51aab OSS-FUZZ: Fix build issue 2026-03-04 17:31:05 +00:00
Arthur Chan 099d9842da OSS-Fuzz: Simplify block_fuzzer
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-03-04 16:38:54 +00:00
Jon Shallow 30875ab127 OSS-FUZZ: Fix discovered issues 2026-03-04 16:18:15 +00:00
Arthur Chan bb639096ab OSS-Fuzz: Fix Makefile for fuzzer to include CFLAGS from OSS-Fuzz
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-03-04 11:05:56 +00:00
Arthur Chan ea9d1cb803 OSS-Fuzz: Fix bias condition
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-03-04 11:05:33 +00:00
Jon Shallow 210cbf378a ASN1: Check for buffer overflows when determining tags and length
Include oss-fuzzer checks.
2026-03-03 10:36:46 +00:00
Arthur Chan e57294c7e6 OSS-Fuzz: Add fuzzer for coap-net targets
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-03-03 10:36:16 +00:00
Arthur Chan 6fd1fbf702 OSS-Fuzz: Add new fuzzer for coap block processing
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-02-23 09:28:27 +00:00
Arthur Chan d2b61c2e49 OSS-Fuzz: Add oscore conf parse fuzzer 2026-02-16 09:44:20 +00:00
Arthur Chan 0bcd5923e7 OSS-Fuzz: Add new fuzzer for oscore pdu decryption
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-02-12 16:14:19 +00:00
Jon Shallow 40aa07a177 oss-fuzz: Remove the need for declaring internal functions 2026-02-02 10:21:41 +00:00
Jon Shallow e59df82300 oss-fuzz: Fix CI oss-fuzz test compilation 2026-01-21 17:04:10 +00:00
Jon Shallow c9135b6b26 Copyright: Update to 2026 2026-01-05 10:37:26 +00:00
raspopov 6f97006daa Fix Windows tests
In Windows, calling the connect function for a socket requires a valid
address. This causes the t_session6 test in the coap_new_client_session()
function in test_session.c to fail.

The fix replaces in6addr_any with in6addr_loopback, as in the adjacent
function call. This does not affect the functionality of the test.

As a result, the tests under Windows are completely successful.
2025-10-02 18:12:50 +01:00
Jon Shallow 67dbe5ac36 testdriver: Suppress log Warning when error detecting 2025-09-16 10:45:03 +01:00
Jon Shallow 0bd03b658e cmake: Remove the need to configure tests/test_common.h 2025-09-12 13:29:17 +01:00
Jon Shallow 9d228feff0 testdriver.c: unit tests failures do not error on exit
Unfortunately tests/testdriver always exited with 0, even if there was a test
suite error.  This meant that CI tests were not picking up any issues.

tests/testdriver now exits with a value of 1 if there is a test suite issue.

Errors corrected in/for the test suite.
2025-05-15 19:22:01 +01:00
Jon Shallow 4289cb072d Copyright: Update to 2025 where appropriate 2025-02-17 09:37:55 +00:00
Jon Shallow 895b0dfd9f CIFuzz: Make sure libcoap is running when calling coap_delete_pdu() 2025-01-28 17:12:37 +00:00
Jon Shallow eff1f38f9f path_query parsing: Remove need to define scratch buffer
Create new options coap_uri_into_optlist(), coap_path_into_optlist() and
coap_query_into_optlist() to be used instead of coap_uri_into_options(),
coap_split_path() and coap_split_query() functions so the requirement
for a scratch buffer is not needed.

Getting the minimum size for a scratch buffer is not straight forward and
potential for unexpected boundary condition errors to occurif too small.

Correct parsing and stripping out of "%2E%2E" ("..") and "%2E" (".")
path segments.  ".." now removes the previous segment (if it exists).

Update documentation and unit testcases.

Update examples to use new options.
2024-06-25 08:23:33 +01:00
Jon Shallow cb20c482b2 locking: Simplify maintenance / debugging /documentation
Update the Public API equivalent of the libcoap functions that need to be
called when locked with a name suffix of _lkd.

Move matching Public API functions out of coap_threadsafe.c to be coded
just ahead of the newly renamed _lkd function.

Properly define the _lkd function in the appropriate _internal.h file for
documentation, removing the #defines from coap_threadsafe_internal.h.

Tag all the Public API functions that have a _lkd function with COAP_API.
COAP_API can then be defined as to what should be done for that function.

Check libcoap library does not call the original Public API function when
it should be calling the _lkd function by marking the Public API not _lkd
functions as deprecated during the libcoap library build.
[Done by the new COAP_API being defined as __attribute__((deprecated)).]

Work in progress for all the functions that need to be multi-thread safe.
2024-05-24 09:09:49 +01:00
Jon Shallow 6e68baa0f7 coap_update_token: Make sure corrected PDU headers are presented to the app 2024-05-21 09:34:11 +01:00
Jon Shallow 15bf66c920 pre-commit: Add more trailing spaces and empty line at end of file checks 2024-05-15 16:04:08 +01:00
Jon Shallow 622050a957 locking: Simplify maintenance / debugging /documentation
Update libcoap functions that need to be called locked with a name
suffix of _locked.

Move matching functions out of coap_threadsafe.c to be coded just ahead
of the newly renamed _locked function.

Properly define the _locked function in the appropriate _internal.h file
for documentation, removing the #defines from coap_threadsafe_internal.h.

Work in progress for all the functions.

Remove coap_lock_* requirements for testdriver (coap_delete_node()).
2024-05-15 15:50:14 +01:00
Jon Shallow 4a94cc7c80 scan-build: Fix warnings 2024-05-09 10:57:16 +01:00
Jon Shallow e3a662a934 wolfSSL: Set up initial port
Includes some porting ideas from qursa-uc3m libcoap-wolfssl work.

Some common ASN1 code moved from coap_gnutls.c to coap_asn1.c to support RPK.

WolfSSL build
$ ./configure --enable-all --enable-dtls13 CFLAGS="-DBUILD_TLS_PSK_WITH_AES_128_CCM -DHAVE_RPK"

Interoperability requirements

DTLS1.3 downgrade requires
https://github.com/eclipse/tinydtls/pull/230
https://github.com/wolfSSL/wolfssl/pull/7367

TLS1.3 downgrade requires
https://github.com/wolfSSL/wolfssl/pull/7367

(D)TLS1.2 use of RPK requires
https://github.com/wolfSSL/wolfssl/pull/7375

MbedTLS using TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256 requires
https://github.com/wolfSSL/wolfssl/pull/7132

GnuTLS using PSK and TLS1.3 requires
https://github.com/wolfSSL/wolfssl/pull/7407
2024-04-16 11:03:24 +01:00
Jon Shallow be37ebb806 Coverity: Fix 1584357, 1584358 and 1584359 2024-03-14 16:27:11 +00:00
Jon Shallow 79840df101 Coverity: Fix 1583538, 1583565 and 1583573
For the test suite, treat these tests as using the public API so locking
is handled by the underlying libcoap.

The only exception is for coap_delete_node() which is an internal function
and expects context to be locked on entry.
2024-03-14 08:53:29 +00:00
Jon Shallow 8237c1d801 Copyright: Update to 2024 2024-01-02 08:45:59 +00:00
Jon Shallow c69c5d5af0 multi-thread: Add in thread safe support
Optional compile time thread safe code supported.

Locking is done at the coap_context_t level, and if enabled is primarily
done coap_threadsafe.c and coap_threadsafe_internal.h.

coap_threadsafe_internal.h causes coap_X() to get mapped to coap_X_locked()
throughout the libcoap library code with the exception of coap_threadsafe.c
if thread safe is enabled.
2023-11-25 11:41:26 +00:00
Jon Shallow 5fd2f89ef0 pdu.c: Fix issue with 269 delta in internal coap_remove_option()
Update unit tests to check for a delta of 13 / 269.
2023-10-04 22:04:19 +01:00
Jon Shallow d295ccb638 Coverity: Fix CID 1469636, 1514378, 1520611 and 1566432 2023-08-19 14:07:21 +01:00
Jon Shallow 76e8b0f029 Coverity: Fix CID 1382587, 1566422-1566493 2023-08-12 14:07:08 +01:00
Jon Shallow e2910a5bf1 naming: Rename remaining *.[ch] files that are not prefixed with coap_
include/coap3/block.h -> include/coap3/coap_block.h
include/coap3/pdu.h -> include/coap3/coap_pdu.h
include/coap3/resource.h -> include/coap3/coap_resource.h
src/block.c -> src/coap_block.c
src/net.c -> src/coap_net.c
src/pdu.c -> src/coap_pdu.c
src/resource.c -> src/coap_resource.c
2023-07-13 08:59:22 +01:00
Jon Shallow e8005c5c27 pre-commit: Include re-styled tests files to checks 2023-07-08 16:37:59 +01:00
Jon Shallow a9b179ab32 Coding: Remove blank lines at ends of files 2023-06-29 09:34:52 +01:00