From d66a455479bafe46141e4de4618a0dda65d6c621 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 14 Mar 2018 17:44:51 +0100 Subject: [PATCH] add check for invalid nof subheaders in MAC PDU --- lib/src/common/pdu.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/src/common/pdu.cc b/lib/src/common/pdu.cc index b3928f11b..b020cde81 100644 --- a/lib/src/common/pdu.cc +++ b/lib/src/common/pdu.cc @@ -132,7 +132,12 @@ uint8_t* sch_pdu::write_packet(srslte::log *log_h) log_h->error("init_rem_len=%d\n", init_rem_len); return NULL; } - + + if (nof_subheaders <= 0) { + log_h->error("Trying to write packet with invalid number of subheaders (nof_subheaders=%d).\n", nof_subheaders); + return NULL; + } + /* If last SDU has zero payload, remove it. FIXME: Why happens this?? */ if (subheaders[nof_subheaders-1].get_payload_size() == 0) { del_subh();