From e6d976d1151408052484423c0d93143b815f55da Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Mon, 21 Feb 2022 18:09:20 +0000 Subject: [PATCH] lib,rlc_am_nr: fixed stack smashing bug that happened when too many NACKs were present in the status report --- lib/include/srsran/rlc/rlc_am_nr_packing.h | 6 ++++-- lib/src/rlc/rlc_am_nr.cc | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/include/srsran/rlc/rlc_am_nr_packing.h b/lib/include/srsran/rlc/rlc_am_nr_packing.h index f52591632..1297880ce 100644 --- a/lib/include/srsran/rlc/rlc_am_nr_packing.h +++ b/lib/include/srsran/rlc/rlc_am_nr_packing.h @@ -19,7 +19,9 @@ namespace srsran { -const uint32_t INVALID_RLC_SN = 0xFFFFFFFF; +const uint32_t RLC_AM_NR_WINDOW_SIZE_12BIT = 4096; +const uint32_t RLC_AM_NR_WINDOW_SIZE_18BIT = 262144; +const uint32_t INVALID_RLC_SN = 0xFFFFFFFF; ///< AM NR PDU header struct rlc_am_nr_pdu_header_t { @@ -82,7 +84,7 @@ typedef struct { uint32_t ack_sn; ///< SN of the next not received RLC Data PDU uint16_t N_nack; ///< number of NACKs uint8_t nack_range; ///< number of consecutively lost RLC SDUs starting from and including NACK_SN - rlc_status_nack_t nacks[RLC_AM_WINDOW_SIZE]; + rlc_status_nack_t nacks[RLC_AM_NR_WINDOW_SIZE_12BIT]; } rlc_am_nr_status_pdu_t; /**************************************************************************** diff --git a/lib/src/rlc/rlc_am_nr.cc b/lib/src/rlc/rlc_am_nr.cc index cd18a8250..bcc81c6b7 100644 --- a/lib/src/rlc/rlc_am_nr.cc +++ b/lib/src/rlc/rlc_am_nr.cc @@ -1149,7 +1149,7 @@ uint32_t rlc_am_nr_rx::get_status_pdu(rlc_am_nr_status_pdu_t* status, uint32_t m { std::unique_lock lock(mutex, std::try_to_lock); if (not lock.owns_lock()) { - return SRSRAN_ERROR; + return 0; } status->N_nack = 0;