From 184199ca054b88a6e769ba479bf4fee2cdec3b86 Mon Sep 17 00:00:00 2001 From: Piotr Gawlowicz Date: Sat, 25 Nov 2023 00:49:46 +0100 Subject: [PATCH] ue,mac: fix mac_rar_pdu_nr::unpack function --- lib/src/mac/mac_rar_pdu_nr.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/src/mac/mac_rar_pdu_nr.cc b/lib/src/mac/mac_rar_pdu_nr.cc index 381663b05..0102ed0f7 100644 --- a/lib/src/mac/mac_rar_pdu_nr.cc +++ b/lib/src/mac/mac_rar_pdu_nr.cc @@ -281,22 +281,24 @@ bool mac_rar_pdu_nr::unpack(const uint8_t* payload, const uint32_t& len) bool ret = false; bool have_more_subpdus = false; uint32_t offset = 0; + bool success = false; remaining_len = len; do { mac_rar_subpdu_nr rar_subpdu(this); - ret = rar_subpdu.read_subpdu(payload + offset); + success = rar_subpdu.read_subpdu(payload + offset); have_more_subpdus = rar_subpdu.has_more_subpdus(); offset += rar_subpdu.get_total_length(); remaining_len -= rar_subpdu.get_total_length(); // only append if subPDU could be read successfully - if (ret == true) { + if (success == true) { subpdus.push_back(rar_subpdu); } + ret |= success; // continue reading as long as subPDUs can be extracted ok and we are not overrunning the PDU length - } while (ret && have_more_subpdus && offset <= len); + } while (success && have_more_subpdus && offset <= len); return ret; }