Commit 64e5a31b authored by Robert Lubos's avatar Robert Lubos Committed by Benjamin Cabé
Browse files

net: coap: Fix coap_packet_is_request() check for empty code

Empty code was incorrectly matched as a request, fix that.

Align coap_handle_request_len() function to behave as documented in the
API documentation - in case of invalid request code (which is also the
case for empty code) -ENOTSUP Should be returned.

Signed-off-by: default avatarRobert Lubos <robert.lubos@nordicsemi.no>
parent 13cd48a4
Loading
Loading
Loading
Loading
+2 −2
Changes for subsys/net/lib/coap/coap.c: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -1172,7 +1172,7 @@ bool coap_packet_is_request(const struct coap_packet *cpkt)
{
	uint8_t code = coap_header_get_code(cpkt);

	return !(code & ~COAP_REQUEST_MASK);
	return (code != COAP_CODE_EMPTY) && !(code & ~COAP_REQUEST_MASK);
}

int coap_handle_request_len(struct coap_packet *cpkt,
@@ -1183,7 +1183,7 @@ int coap_handle_request_len(struct coap_packet *cpkt,
			    struct sockaddr *addr, socklen_t addr_len)
{
	if (!coap_packet_is_request(cpkt)) {
		return 0;
		return -ENOTSUP;
	}

	/* FIXME: deal with hierarchical resources */