From 1365dea39a6129a9b7e8c579537e12ffef1558f6 Mon Sep 17 00:00:00 2001 From: Jon Shallow Date: Fri, 27 Apr 2018 15:45:32 +0100 Subject: [PATCH] src/coap_session.c: Verify tid is not being re-used in a session Check that the same tid is not getting re-used in violation of RFC7252 in coap_session_delay_pdu() --- src/coap_session.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/coap_session.c b/src/coap_session.c index 918e8f8d..a1396b77 100644 --- a/src/coap_session.c +++ b/src/coap_session.c @@ -252,6 +252,14 @@ coap_session_delay_pdu(coap_session_t *session, coap_pdu_t *pdu, node->session = NULL; node->t = 0; } else { + coap_queue_t *q = NULL; + /* Check that the same tid is not getting re-used in violation of RFC7252 */ + LL_FOREACH(session->sendqueue, q) { + if (q->id == pdu->tid) { + coap_log(LOG_ERR, "** %s tid=%d: already in-use - dropped\n", coap_session_str(session), pdu->tid); + return COAP_INVALID_TID; + } + } node = coap_new_node(); if (node == NULL) return COAP_INVALID_TID;