Commit Graph
2735 Commits
Author SHA1 Message Date
obgm 9727399c0b Merge pull request #832 from obgm/fix-block2-nullref
block.c: Fix possible null-pointer dereference
2022-02-21 17:41:49 +01:00
obgm ee171b2b8c Merge pull request #826 from mrdeep1/proxy_critical_options
Proxy: Support unknown Critical but Safe-To-Forward options
2022-02-21 17:40:03 +01:00
obgm 52c96ba9b3 Merge pull request #829 from mrdeep1/vs_openssl
coap_openssl.c: Support Microsoft VS builds
2022-02-21 14:44:41 +01:00
Olaf Bergmann b42c184f74 block.c: Fix possible null-pointer dereference
Commit 9cb2f62a3 [1] has introduced library-internal handling of
Block1 and Block2 requests. To add the data to the response body the
function coap_add_data_large_internal() is used.

This change calls the function independent of a Block2 request unless
request is NULL. The response code is set to 500 if
coap_add_data_large_internal() failed.

Fixes Coverity-Id 1514379

[1] https://github.com/obgm/libcoap/commit/9cb2f62a3eef2e0aeb682615b785d4734b473bd4
2022-02-21 14:10:16 +01:00
Jon Shallow df72a53f2d coap_openssl.c: Support Microsoft VS builds
Correct reported errors

Update workflow for ms-build to include OpenSSL.
2022-02-21 12:37:44 +00:00
Olaf Bergmann 0f76881802 autogen.sh: Fix missing file ar-lib
After autogen.sh --clean, all auto-generated files need to be
re-created. Before this has happened, autoreconf complains
with

  configure.ac: error: required file 'ar-lib' not found

and signals an error on exit.

This change fixes the issue by touching ar-lib to force creation of an
empty file if it does not exist. Because autoreconf is called with the
options --force --install, this file will get replaced afterwards.
2022-02-21 13:04:49 +01:00
obgm ce88036fc4 Merge pull request #830 from mrdeep1/distribution
doc/Makefile.am: Include module_api_wrap.h in a distribution
2022-02-21 11:02:39 +01:00
obgm 9a0d1c2fe4 Merge pull request #831 from mrdeep1/warn_error
builds: Set CFLAGS += -Werror in all linux subdirectory compilations
2022-02-21 11:01:35 +01:00
Jon Shallow 19928e81bd builds: Set CFLAGS += -Werror in all linux subdirectory compilations 2022-02-18 14:23:43 +00:00
Jon Shallow b2ad43319a doc/Makefile.am: Include module_api_wrap.h in a distribution 2022-02-18 13:34:24 +00:00
Jon Shallow dfc678c33b Proxy: Support unknown Critical but Safe-To-Forward options
The CoAP Proxy may not know how to handle a Critical option, but if it
is safe to forward it should be able to handle this.

RFRC7252 5.4.1
   Critical/elective rules apply to non-proxying endpoints.  A proxy
   processes options based on Unsafe/Safe-to-Forward classes as defined
   in Section 5.7.

If this is an incoming proxy type request special case any
critical options that are safe to forward.

Track ongoing sessions from an enabled proxy server so unknown critical
response options can be passed back to the originating requestor.

Update coap-server to handle Proxy-Scheme for proxying.

Update tests to use critical option 25 instead of 9.
2022-02-18 12:51:35 +00:00
obgm 69b865cd3b Merge pull request #823 from mrdeep1/pdu_setup_docs
coap_pdu_setup.txt.in: Clarify / more make readable the pdu setup information
2022-02-16 09:15:32 +01:00
Jon Shallow 93f2738c45 coap_pdu_setup.txt.in: Clarify / more make readable the pdu setup information 2022-02-14 17:05:00 +00:00
obgm a5eb61d25d Merge pull request #824 from mrdeep1/windows_2022
github workflow: Support windows-2022
2022-02-10 11:15:30 +01:00
obgm f9c3e13a18 Merge pull request #804 from mrdeep1/insert_option
pdu.c: Fix coap_insert_option with delta = 269
2022-02-10 10:21:43 +01:00
Jon Shallow 5b32d716fa github workflow: Support windows-2022
The provided host for windows-latest is migrating across from
windows-2019 to windows-2022 on github.  This allows things to be built on
a windows-2022 system.
2022-02-09 21:44:37 +00:00
Jon Shallow bd9ced550e pdu.c: Fix coap_insert_option with delta = 269
Fix off-by-one error for option delta = 269.

Correct / clarify the tests in coap_insert_option() when working out extended
option delta for inserting new option.
2022-02-09 16:51:39 +00:00
Olaf Bergmann ba585f848f [OSS-Fuzz] pdu_parse_target.c: Check result of coap_pdu_parse()
When coap_pdu_parse() returns 0, the contents of pdu are undefined and
must not be processed. This change proceeds fuzzer tests only if parsing
succeeded.

Fixes OSS-Fuzz issue 44503 [1]

[1] https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44503
2022-02-09 16:34:35 +01:00
Olaf Bergmann a2e0046c80 [OSS-Fuzz] pdu_parse_target.c: Fix compiler warning
Declare prototype for internal function coap_pdu_encode_header().
2022-02-09 16:32:00 +01:00
obgm afb4f2b7a1 Merge pull request #812 from mrdeep1/multiple_sessions
sessions: Prevent multiple client session confusion
2022-02-09 12:38:35 +01:00
Jon Shallow b3d503cbff sessions: Prevent multiple client session confusion
Prevent multiple coap_new_client_session*() calls that are connecting to
the same server/port being bound to the same local ip/port.

Update logging for session creation / removal to easily differentiate between
sessions that have the same 4-tuple.

Document that coap_new_endpoint() is not required in client based code.

If coap-client '-p port' but not '-a addr' is provided, fix code so that
the port is bound to.

Only remove outstanding CON requests with token matches if there is an
ACK response.

Update the logging to differentiate between the 6 occurrences where the mid
is removed.
2022-02-08 16:52:15 +00:00
obgm 6aa967cee1 Merge pull request #809 from mrdeep1/cmake_tinydtls
cmake_coap_config.h.in: Fix definitions for when building with tinydtls
2022-02-08 15:43:36 +01:00
obgm dc4994f1d1 Merge pull request #821 from mrdeep1/block_docs
coap_block.txt.in: Clarify / more make readable the block handling information
2022-02-08 15:42:36 +01:00
obgm 838b2d9e39 Merge pull request #813 from mrdeep1/pdu_ordering
pdu building: Enforce the application order of building a PDU
2022-02-08 15:42:01 +01:00
Jon Shallow 726b9630e5 coap_block.txt.in: Clarify / more make readable the block handling information 2022-02-08 14:16:27 +00:00
Jon Shallow 756bb04239 pdu building: Enforce the application order of building a PDU
Make coap_add_option() invalid after calling a coap_add_data*() function.
Add in internal support for adding options to PDUs that contain data with
a replacement coap_add_option_internal() function.  Call this new function
in the appropriate places in the libcoap src.

Add coap_log warnings when the application tries to build a PDU in the wrong
order and then return failure.

Update documentation re-inforcing the PDU building order.
2022-02-08 14:14:51 +00:00
obgm 0d6c7d686b Merge pull request #819 from mrdeep1/coap_access_pdu
coap_pdu_access.txt.in: Add in documentation for coap_get_uri_path()
2022-02-07 17:33:00 +01:00
obgm 6504b667d3 Merge pull request #818 from mrdeep1/proxy_uri
proxy_uri: Fix handling the resource for uri path in Proxy-Uri
2022-02-07 17:32:31 +01:00
Jon Shallow c02ca5f097 coap_pdu_access.txt.in: Add in documentation for coap_get_uri_path()
Also document the return values of the various functions.
2022-02-07 14:50:03 +00:00
Jon Shallow aaf6115594 proxy_uri: Fix handling the resource for uri path in Proxy-Uri
If the server recieving a Proxy request determines that it is the final
endpoint of the request, the resource that the request was sent to
was wrong. The update to coap_get_uri_path() fixes this issue.

There is now also parameter support for the proxy definition for the
coap-server where any defined host is treated as being the final endpoint
is in:

  coap-server -P ,

This allows any actual server to be the final endpoint of any proxy request
without have to define all the names or IP addresses that the coap-server is
known by.  Note that if there is nothing following the , (comma), anything
before the , (comma) will never be used.

Documentation updated.
2022-02-07 14:46:46 +00:00
obgm 1fceff7cc3 Merge pull request #814 from mrdeep1/build_version
versioning: Make current git describe available
2022-02-07 14:38:34 +01:00
obgm 5e793d4852 Merge pull request #816 from mrdeep1/coap_encode
coap_pdu_setup.txt.in: Better document coap_encode_var_safe8()
2022-02-07 13:24:47 +01:00
Jon Shallow a8c00f2af9 coap_pdu_setup.txt.in: Better document coap_encode_var_safe8()
Document return value can be 0 for both being valid and returning on error.
Same is true for coap_encode_var_safe().

[Error should assert() by default]
2022-02-02 21:37:54 +00:00
Jon Shallow 64e5641017 versioning: Make current git describe available
Add new function coap_package_build() which returns "git describe --tags"
if available at library build time, else standard package version.

The value of "git describe --tags" is created at run time and passed in as
a compiler -D definition.

Update copyright end dates for updated files.
2022-02-02 11:24:52 +00:00
Jon Shallow 0a16d790ce cmake_coap_config.h.in: Fix definitions for when building with tinydtls
Build the coap_config.h file in the same way that the make system does
without wrapping the definitions with ""
2022-01-01 13:26:08 +00:00
obgm 2a329e1c76 Merge pull request #771 from mrdeep1/server_post
coap-server: Add in POST support for unknown request handler
2021-12-22 15:31:37 +01:00
obgm fce44ba52a Merge pull request #779 from mrdeep1/mid_testing
coap_session.c: Do not check for duplicate mids if reliable protocol
2021-12-22 15:05:02 +01:00
Jon Shallow 17aaa81b5a Caching: Highlight requirements ignoring certain CoAP Options
When using the cache logic to build up the data of a body transferred over
several blocks, the BLOCK options must be excluded when deriving the cache key.

Update documentation reminding the user of the need to do this.
2021-12-22 13:38:04 +00:00
obgm 17f7fe8c52 Merge pull request #780 from mrdeep1/multicast_get
coap-client.c: Allow time for all server responses to mcast
2021-12-22 14:16:36 +01:00
obgm 0da7c50c54 Merge pull request #790 from mrdeep1/mbedtls_lib
configure.ac: Fix have mbedtls lib, but no mbedtls-dev issue
2021-12-22 14:15:03 +01:00
obgm ffc1f4f938 Merge pull request #791 from mrdeep1/resource_delete
resource.c: Support deleting resources that have not yet been added
2021-12-22 14:04:05 +01:00
Jon Shallow 74582eddde resource.c: Support deleting resources that have not yet been added
Support deleting a resource both before and after calling
coap_delete_resource().

Make the coap_delete_resource() usage in examples less complex.
2021-12-22 12:59:32 +00:00
obgm efe18d2845 Merge pull request #781 from mrdeep1/large_tcp_writes
coap_write_session: Account correctly for partial TCP writes
2021-12-22 13:55:28 +01:00
obgm dc0db3a238 Merge pull request #796 from mrdeep1/block_boundaries
block: Check block size space correctly
2021-12-22 12:04:27 +01:00
obgm cbe387614c Merge pull request #799 from mrdeep1/cmake_bin_install
cmake: Install example programs if examples enabled
2021-12-22 12:02:49 +01:00
obgm 470f36b45e Merge pull request #801 from mrdeep1/request_overlap
block.c: Do not match large response if no Block2 option in request
2021-12-22 12:02:27 +01:00
obgm 571807bcc5 Merge pull request #803 from mrdeep1/request_handler_log
request_handler: Report only when app's request handler is actually called
2021-12-22 12:00:13 +01:00
Jon Shallow 32d2d0e1c6 request_handler: Report only when app's request handler is actually called
Aids tracking issues with the libcoap block handling logic to easily
differentiate when libcoap sends a response and when app handler is called
to send a response.
2021-12-22 10:23:34 +00:00
Jon Shallow 5dc2dfca86 block.c: Do not match large response if no Block2 option in request
Allows a following request not to match cached multi-payload large response.
2021-12-20 20:31:37 +00:00
Jon Shallow 18888cd0dd cmake: Install example programs if examples enabled 2021-12-20 12:24:00 +00:00