From 9e3cdebae153a1858eccfe7d24fc82d59629f8fc Mon Sep 17 00:00:00 2001
From: Martine Lenders <mail@martine-lenders.eu>
Date: Sat, 29 Dec 2018 22:54:52 +0100
Subject: [PATCH] gnrc_sixlowpan_frag: check if own message queue is full

When issueing the sending of the next fragment the current version of
`gnrc_sixlowpan_frag` doesn't check if the queue is full. This leads to
leakage of the packet buffer, since when it is full, the package never
gets released.

This change adds a checks and error exits in case the queue is full.
---
 .../gnrc/network_layer/sixlowpan/frag/gnrc_sixlowpan_frag.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sys/net/gnrc/network_layer/sixlowpan/frag/gnrc_sixlowpan_frag.c b/sys/net/gnrc/network_layer/sixlowpan/frag/gnrc_sixlowpan_frag.c
index 4f6d4a656b..eb781ef613 100644
--- a/sys/net/gnrc/network_layer/sixlowpan/frag/gnrc_sixlowpan_frag.c
+++ b/sys/net/gnrc/network_layer/sixlowpan/frag/gnrc_sixlowpan_frag.c
@@ -287,7 +287,11 @@ void gnrc_sixlowpan_frag_send(gnrc_pktsnip_t *pkt, void *ctx, unsigned page)
     fragment_msg->offset += res;
     msg.type = GNRC_SIXLOWPAN_MSG_FRAG_SND,
     msg.content.ptr = fragment_msg;
-    msg_send_to_self(&msg);
+    if (msg_send_to_self(&msg) == 0) {
+        printf("6lo frag: message queue full, can't issue next fragment "
+              "sending\n");
+        goto error;
+    }
     thread_yield();
     return;
 error:
-- 
GitLab