This adds a unit test to nanocoap that checks that nanocoap's
`coap_parse()` indeed returns `-EBADMSG` when a CoAP Option exceeds the
packet's boundaries. This is relied upon in the option parsing code
at various places by omitting the bounds checking, so we should better
make sure that bounds checking is done correctly here and those
functions can indeed rely upon bounds checking being done correctly
before.
An RST message has no token, so don't reply with a token when sending
RST.
This also adds unit tests to ensure this this exact bug does not sneak
back in.
This increases test coverage for coap_build_reply_header() for the case
that extended tokens are used. The test validates the correctness of
the return value and the correctness of the assembled reply.
Previously the corner case when RFC 8974 extended TKL fields are used
the result of coap_get_totel_hdr_len() was not tested, resulting in a
bug slipping through the test. This increase the test coverage.
Implemented a check in coap_parse() to verify if TKL value is within valid range as specified by RFC7252. The token length must be within 0-8 range, any other value should be considered as invalid and the packet should produce message format error.
A test case was added to tests-nanocoap.c to verify correct behavior in case of TKL in range and out of range.
Update sys/net/application_layer/nanocoap/nanocoap.c
Prefixed debug message with module name and abbreviations expanded.
Co-authored-by: Martine Lenders <mail@martine-lenders.eu>
Update sys/net/application_layer/nanocoap/nanocoap.c
Prefixed debug message with module name and abbreviations expanded.
Co-authored-by: Martine Lenders <mail@martine-lenders.eu>