bugfix: #24 Empty ACK improperly includes Token

Included the patch proposed by tbahls to fix this issue. Now, the
ACK message is always truncated to its bare header when the message code
is 0.00.
This commit is contained in:
Olaf Bergmann committed 2014-02-25 19:03:25 +01:00
1 parent 909cccd05d
commit e2dfed6035
1 file changed
+11
+11
View File
@@ -1403,6 +1403,17 @@ handle_request(coap_context_t *context, coap_queue_t *node) {
h(context, resource, &node->remote,
node->pdu, &token, response);
/* If original request contained a token, and the registered
* application handler made no changes to the response, then
* this is an empty ACK with a token, which is a malformed
* PDU */
if ((response->hdr->type == COAP_MESSAGE_ACK)
&& (response->hdr->code == 0)) {
/* Remove token from otherwise-empty acknowledgment PDU */
response->hdr->token_length = 0;
response->length = sizeof(coap_hdr_t);
}
if (response->hdr->type != COAP_MESSAGE_NON ||
(response->hdr->code >= 64
&& !coap_is_mcast(&node->local))) {