You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by "janc.apache.org via commits" <co...@mynewt.apache.org> on 2026/10/31 22:12:08 UTC

(mynewt-core) 01/02: net/oic: Fix use of freed CoAP transaction

This is an automated email from the ASF dual-hosted git repository.

sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit bd93db70d5a5710a8864dcef4b78f6b196011496
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Fri Oct 30 14:52:12 2026 +0100

    net/oic: Fix use of freed CoAP transaction
    
    Pointer to transaction used for response was kept in static variable
    in coap_receive(). It was not cleared after response transaction was
    sent and freed, so following message that failed to be parsed or
    handled cleared that transaction again, putting the same memory block
    back to transactions pool multiple times. This could corrupt pool and
    result in transaction being used by multiple users.
    
    Keep transaction pointer in local variable, it is not used across
    coap_receive() calls.
    
    Assisted-by: Claude:claude-opus-5-5
---
 net/oic/src/messaging/coap/engine.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/oic/src/messaging/coap/engine.c b/net/oic/src/messaging/coap/engine.c
index c18dac338..6211bd3d8 100644
--- a/net/oic/src/messaging/coap/engine.c
+++ b/net/oic/src/messaging/coap/engine.c
@@ -58,7 +58,7 @@ coap_receive(struct os_mbuf **mp)
     struct os_mbuf *m;
     static struct coap_packet_rx message[1];
     static struct coap_packet response[1];
-    static coap_transaction_t *transaction = NULL;
+    coap_transaction_t *transaction = NULL;
     struct os_mbuf *rsp;
     struct oc_endpoint endpoint; /* XXX */